-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript04.html
80 lines (69 loc) · 2.7 KB
/
javascript04.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>자바스크립트 기본04 - 비교연산, 논리연산, 기타연산</title>
</head>
<body>
<script>
var x=200, y=300, z=100;
// | |
// > >
// < <
//대입연산자
document.write("<h2>대입연산자</h2>")
x+=3;
document.write("<br>x+=3의 결과: " +x);
x-=4;
document.write("<br>x-=4의 결과: " +x);
x*=2;
document.write("<br>x*=2의 결과: " +x);
x/=3;
document.write("<br>x/=3의 결과: " +x);
x%=29;
document.write("<br>x%=29의 결과: " +x);
//자바스크립트 문법 준수: ESLint 설치 필요
x=200;
y=200;
//증감연산자
document.write("<hr><h2>증감연산자</h2>");
document.write("<br>x++의 결과: "+(x++));
document.write("<br>++y의 결과: "+(++y));
document.write("<br>x--의 결과: "+(x--));
document.write("<br>--y의 결과: "+(--y));
//비교연산자
document.write("<hr><h2>비교연산</h2>")
document.write("<br> x>y: "+(x>y));
document.write("<br> x<y: "+(x<y));
document.write("<br> x>=y: "+(x>=y));
document.write("<br> x<=y: "+(x<=y));
document.write("<br> x==y: "+(x==y));
document.write("<br> x!=<y: "+(x!=y));
document.write("<br> x===y: "+(x===y)); //타입과 값이 모두 일치
document.write("<br> x!==y: "+(x!==y)); //타입 또는 값이 다르면
//논리연산자
document.write("<hr><h2>논리연산</h2>")
document.write("<br> x>y && y==200: " +(x>y && y==200));
document.write("<br> x>y || y==200: " +(x>y || y==200));
document.write("<br> !(x<y): " +(!(x<y)));
//비트연산자
document.write("<hr><h2>비트연산</h2>")
document.write("<br> x & y: "+(x & y)); //and
document.write("<br> x | y: "+(x | y)); //or
document.write("<br> x ^ y: "+(x ^ y)); //xor
document.write("<br> x >> 2: "+(x >> 2)); //오른쪽 shift =>/2
document.write("<br> x << 2: "+(x << 2)); //왼쪽 shift =>*2
document.write("<br> ~y: "+(~x)); //complement(보수)
//삼항 연산자
var = a (x>y) ? x : y;
document.write("<hr><h2>삼항 연산자</h2> -> (x>y) ? x : y => "+a+"<br><br>");
var a = typeof "김보경";
document.write(a + "<br>")
var a = typeof 1004;
document.write(a + "<br>")
var a = typeof 6.28;
document.write(a + "<br>")
</script>
</body>
</html>