number, bigInt

ES
ES2019
비고
숫자는 자동으로 number 타입으로 메모리를 할당함. number범위는 (-2^53 ~ 2^53) 까지. 이를 넘어서는 숫자를 쓰려면 bigInt 타입으로, 숫자 뒤에 'n' 붙이면 됨.
Tags
data-type
bigInt
short, int, long, float 등 생각할 것 없이 JS에서는 그냥 number type쓰면 됨.
JS는 런타임에 동적으로 타입이 결정되므로 그냥 숫자를 쓰면 알아서 number 타입으로 그만큼의 메모리가 할당됨.
const age = 26; const height = 170.6; typeof age; // number typeof height; // number
 
number의 표현범위는 -2^53~2^53 까지인데, 이를 넘어서는 숫자를 쓰고싶다면 bigInt 타입을 쓰면 됨.
bigInt 타입 사용법 : 숫자 뒤에 'n' 붙이면 됨.
const bigIntTest = 10n;