This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// isNaN 함수는 지정한 값이 NaN인지 확인하고 그 결과를 불리언 값으로 반환한다. | |
isNaN(NaN); // true | |
isNaN(10); // false | |
isNaN(1 + undefined); // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 대소 관계 비교 | |
5 > 0; // true | |
5 < 0; // false | |
5 >= 0; // true | |
5 >= 0; // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x = 2; | |
// 2 % 2는 0이고 0은 false로 암묵적 타입 변환된다. | |
let result = x % 2 ? "홀수" : "짝수"; | |
console.log(result); // 짝수 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 논리합(||) 연산자 | |
true || true; // true | |
true || false; // true | |
false || true; // true | |
false || false; // false | |
// 논리곱(&&) 연산자 | |
true && true; // true | |
true && false; // false | |
false && true; // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 암묵적 타입 변환 | |
!0; // true | |
!"Hello"; // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 단축 평가 | |
"Cat" && "Dog"; // 'Dog' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x, y, z; | |
(x = 1), (y = 2), (z = 3); // 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 * 2 + 3; // 23 | |
// 그룹 연산자를 사용하여 우선순위를 조절 | |
10 * (2 + 3); // 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typeof ""; // → "string" | |
typeof 1; // → "number" | |
typeof NaN; // → "number" | |
typeof true; // → "boolean" | |
typeof undefined; // → "undefined" | |
typeof symbol(); // → "symbol" | |
typeof null; // → "object" | |
typeof []; // → "object" | |
typeof {}; // → "object" | |
typeof new Date(); // → "object" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let foo = null; | |
typeof foo === null; // → false | |
foo === null; // → true |