종류
- primitive
- single item: number, string, boolean, null, undefined, symbol
- object
- box container
- function
- first-class function
특징
- 자바스크립트 타입에는 크게 두 가지의 타입이 존재하는데, primitive type(기본 타입) 과 reference type(참조 타입) 이 존재한다.
- 자바스크립트 런타임 시 선언된 변수의 타입이 정해진다.
Number
- number(integer, decimal number, infinity, -infinity, NaN),
- bigint
const count = 17;
const size = 17.1;
const infinity = 1 / 0;
const negativeInfinity = -1 / 0;
const nAn = 'not a number' / 2;
const bigInt = 1234567890123456789012345678901234567890n;
console.log(`value: ${count}, type: ${typeof count}`); // value: 17, type: number
console.log(`value: ${size}, type: ${typeof size}`); // value: 17.1, type: number
console.log(`value: ${infinity}, type: ${typeof infinity}`); // value: Infinity, type: number
console.log(`value: ${negativeInfinity}, type: ${typeof negativeInfinity}`);
// value: -Infinity, type: number
console.log(`value: ${nAn}, type: ${typeof nAn}`);
// value: NaN, type: number
console.log(`value: ${bigInt}, type: ${typeof bigInt}`);
// value: 1234567890123456789012345678901234567890, type: bigint
String