JavaScript의 타입
JavaScript 언어의 타입은 원시 값과 객체로 나뉩니다.
·원시 값 (언어의 최고 로우레벨에서 직접 표현되는 불변 데이터)
1. Boolean 타입
2. Null 타입
3. Undefined 타입
4. Number 타입
5. BigInt 타입
6. String 타입
7. Symbol 타입
·객체 (속성의 컬렉션)
참고: https://developer.mozilla.org/ko/docs/Web/JavaScript/Data_structures
typeof 연산자란?
typeof 연산자는 피연산자의 평가 전 자료형을 나타내는 문자열을 반환합니다.
typeof 연산자 사용법
typeof 값;
typeof 연산자 다음에 타입을 확인하고자 하는 값을 넣어줍니다.
개발자 도구를 이용해 실습하기
console.log(typeof 1) // number
console.log(typeof '1') // string
console.log(typeof (1 < 2)) // boolean
let number = 1;
console.log(typeof number) // number
let string = '1';
console.log(typeof string) // string
console.log(typeof 42);
// expected output: "number"
console.log(typeof 'blubber');
// expected output: "string"
console.log(typeof true);
// expected output: "boolean"
console.log(typeof undeclaredVariable);
// expected output: "undefined"
참고: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/typeof