: 객체를 제외한 모든 타입
: 메서드를 갖지 않음
: 비어있는 값을 표현
⚠️ 주의
typeof로null을 확인했을 때 'object'라는 결과가 반환됨. (언어 자체 오류)typeof null === 'object' // true
: 값이 할당되지 않은 변수/인수
: 참/거짓
: -(253-1) ~ (253-1) 사이의 모든 숫자
Math.pow(2, 53) - 1 === Number.MAX_SAFE_INTEGER // true
-(Math.pow(2, 53) - 1) === Number.MIN_SAFE_INTEGER // true
9007199254740992 === 9007199254740993 // 다른데 true
let num = 2.5e5;
console.log(num); // 250000
console.log(typeof num); // number
let num = 'Hello' / 2;
console.log(num); // NaN
console.log(typeof num); // number
let num = 1 / 0;
console.log(num); // Infinity
console.log(typeof num); // number
let num = -1 / 0;
console.log(num); // -Infinity
console.log(typeof num); // number
: number가 다룰 수 있는 숫자 크기의 제한을 극복, 더 큰 숫자를 저장할 수 있게 해줌.
: 숫자 뒤에 n을 붙이거나 BigInt()를 사용하여 생성
9007199254740992n === BigInt(9007199254740993) // true
9007199254740992 == 9007199254740992n // true
9007199254740992 === 9007199254740992n // false
: 문자열
: '', "", ``로 감싸져있다.
백틱으로 작성한 문자열: 템플릿 리터럴
- 줄바꿈이 가능
- 문자열 내부에 표현식을 쓸 수 있다
: 중복되지 않는 어떠한 고유한 값을 나타내기 위해 사용
: Symbol()을 사용하여 생성
: 동일한 값을 사용하기 위해서는 Symbol.for을 사용
Symbol('key') === Symbol('key') // false
Symbol.for('hello') === Symbol.for('hello') // true
typeof [] // 'object'
typeof {} // 'object'
function fn () {}
typeof fn // 'function'
boolean 타입인 false가 아니라도 조건문에서 false로 취급되는 값
| 값 | 타입 |
|---|---|
| false | boolean |
| null | null |
| undefined | undefined |
| NaN | Number |
| 0, -0, 0n, 0x0n | Number, BigInt |
| '', "", `` | String |
모던 리액트 Deep Dive