-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex04.html
More file actions
71 lines (66 loc) · 2.55 KB
/
ex04.html
File metadata and controls
71 lines (66 loc) · 2.55 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>기본 연산</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);
// 증감 연산자
document.write("<h2>증감 연산자</h2>");
x++;
document.write("<br>x++: "+x);
++x;
document.write("<br>++x: "+x);
x--;
document.write("<br>x--: "+x);
--x;
document.write("<br>--x: "+x);
// 비교 연산자
document.write("<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("<h2>논리 연산자</h2>");
document.write("<br> true&&true: "+(true&&true));
document.write("<br> true&&false "+(true&&false));
document.write("<br> false||false: "+(false||false));
document.write("<br> true||false "+(true||false));
document.write("<br> !true: "+(!true));
// 비트 연산자
document.write("<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> y>>2: "+(y>>2));
document.write("<br> y<<2: "+(y<<2));
document.write("<br> ~y: "+(~y)); // ~을 silbing 기호라고도 부른다. complement 보수
var a = (x>y)? x : y;
document.write("<h2>삼항 연산자</h2>(x>y)? x : y =>"+a+"<br>");
document.write("<br>type 김일일: "+typeof("김일일"));
document.write("<br>type 1004: "+typeof(1004));
document.write("<br>type 3.14: "+typeof(3.14));
</script>
<br><br><br><br><br><br><br>
</body>
</html>