조건? true:false
true, false부분 타입 같아야 합니다!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h3>조건 연산</h3><hr>
<script>
var a = 3, b = 5;
document.writeln((a>b)?a:b);
document.writeln((a>b)?"a가 큽니다.":"b가 큽니다.");
</script>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
?가 들어간다.
true면 앞의 값(a), false면 뒤의 값(b)이 출력된다.
두개의 타입이 동일해야한다(정수면 정수, 문자면 문자)
출력값
'Javascript' 카테고리의 다른 글
문자열 연산자 서론에 설명 조금 더하기 //String operator (0) | 2020.03.10 |
---|---|
함수들 - alert() prompt() confirm() (0) | 2020.03.09 |
비교 연산자, 논리 연산자 // Comparison operator, Logical operator (0) | 2020.03.09 |
산술 연산자 // Arithmetic Operators (0) | 2020.03.09 |
상수 //literal (0) | 2020.03.09 |