
자바스크립트에는 다양한 타입이 존재한다.
number, string, boolean, list, object, undefined, function..
만약, 내가 선언한 변수의 타입을 알고싶다면 어떻게 해야될까?
typeof
변수의 타입을 확인하고 싶을 때는 typeof 연산자를 사용하면된다.
let age = 27; // age라는 변수에 27이라는 나이값 할당
let name = 'kim';
let maritalStatus = true;
console.log(typeof(age)) // number
console.log(typeof(name)) // string
console.log(typeof(maritalStatus)) // boolean
위의 코드처럼 typeof 뒤에 타입을 알고자하는 변수를 적게되면 그 변수의 타입을 반환해준다.