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;