typeof 값 => 자료형을 문자열로 변환
console.log(typeof 101); // number -> 숫자형
console.log(typeof 'Codeit'); // string -> 문자형
console.log(typeof true); // boolean -> 불린형
console.log(typeof 'true'); // string -> 문자형
console.log(typeof 1); // number
console.log(typeof 1.0); // number
console.log(typeof '1'); // string
console.log(typeof "1"); // string
console.log(typeof `1`); // string
let name = 'Codeit';
function sayHello() {
console.log('Hello');
};
console.log(typeof name); // string -> 문자형
console.log(typeof sayHello); // function -> 함수
console.log(typeof 'Hello' + 'Codeit'); // stringCodeit
console.log(typeof 8 - 3); // NaN
console.log(typeof ('Hello' + 'Codeit')); //string
console.log(typeof (8 - 3)); // number
- typeof 연산자의 경우 사칙연산보다 우선순위가 높음
- 숫자형의 경우NaN로 반환 -> 괄호를 활용하여 우선순위를 변경해줌