Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript1.js
More file actions
Latest commit
158 lines (131 loc) · 3.33 KB
/
Copy pathjavascript1.js
File metadata and controls
158 lines (131 loc) · 3.33 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
letsym1=Symbol();
letsym2=Symbol();
console.log(sym1==sym2);//false
letheart=Symbol('하트');
console.log(heart)
console.log(heart.toString());
letheart1=Symbol.for('하트');
letheart2=Symbol.for("하트")
console.log(heart1==heart2)
console.log(Symbol.keyFor(heart))
console.log(Symbol.keyFor(heart1))
lett=`Man errs as long as
he strives`;
lett2="Man errs as long as\nhe strives";
lett3=`Man errs as long as\nhe strives`;
lett4=String.raw`Man errs as long as\nhe strives`;
console.log(t)
console.log(t2)
console.log(t3)
console.log(t4)
leta=2,b=3;
console.log(`${a} + ${b} = ${a+b}`);
letnow=newDate();
console.log(`오늘은 ${now.getMonth()+1} 월 ${now.getDate()} 일입니다.`)
letcard={
suit : "하트",
rank: "A"
};
card.suit//하트
card["rank"]//A
card.color//undefined
card.value=14;//value 프로퍼티 추가
console.log(card);
deletecard.value;//value 프로퍼티 삭제
console.log(card);
letmethod={
method1 : ()=>{
console.log("hello!");
},
method2 : ()=>{
console.log("hello world!");
}
};
method.method1();
method.method2();
functionsquare(x){
returnx*x;
}
console.log(square(2))
functiondist(p,q){
letdx=q.x-p.x;
letdy=q.y-p.y;
returnMath.sqrt(dx*dx+dy+dy);
}
letp1={
x: 1,
y:1
};
letp2={
x: 4,
y: 5
};
console.log(dist(p1,p2));
leta1='global';
functionf(){
a1='local';
console.log(a1);
returna1;
}
f()
console.log(a1)
functionCard(suit,rank){
this.suit=suit;
this.rank=rank;
}
varcards=newCard("하트","A");
console.log(cards);
console.log(`${now.getFullYear()} 년 ${now.getMonth()+1} 월 ${now.getDate()} 일`)
//getFullYear() 연도
//getMonth() 월 0부터 시작
//getDate() 날짜
//getDay() 요일
//getHours() 시간
//getMinutes() 분
//getSeconds() 초
//getMilliseconds() 밀리초
//toString 문자로 나타냄
//toLocaleString() 지역화된 시간과 날짜 정보
//toLocaleDateString() 지역화된 날짜 정보
//toLocaleTimeString() 지역화된 시간 정보
//getUTCHours() UTC 시간
//toUTCString() UTC 시간과 날짜 정보
letsquares=newFunction("x","return x*x");
console.log(squares(5))
letarray=[1,2,3,4];
console.log(array)//[1,2,3,4]
console.log(array.length)
letarray2=newArray(1,2,3,4);
console.log(array2)//[1,2,3,4]
console.log(array[2])//3
array[4]=5;
array.push(6);
console.log(array)
deletearray[5]
console.log(array)
//희소배열
letarray3=[1,2,3];
array3[4]="5";
console.log(array3)
console.log(0/0)//NaN
console.log("one"*1)//NaN
console.log(true+true)//2
console.log(1+null)//1
console.log(1+undefined)//NaN
// Math.random() //0이상 1미만의 난수
// Math.round() //반올림
// Math.trunc() //정수부
console.log(Math.trunc(Math.round(Math.random()*10+1)))
// == 값이 같음
// != 값이 다름
// === 값과 타입이 같음
// !== 값과 타입이 다름
// << 왼쪽 시프트 105 << 3 = 840
// >> 부호 있는 오른쪽 시프트 -91 >> 3 = -12
// >>> 부호 없는 오른쪽 시프트 -91 >>> 3 = 536870900
// typeof 데이터 타입을 조사한다
// void 정의 되지 않는 값을 반환
// delete 객체의 프로퍼티나 배열 요소 제거
// new 새로운 객체를 생성
// instanceof 객체의 종류 확인
// ?: 조건 연산자