let a;
console.log(typeof a); // 출력: "undefined"

console.log(typeof true); // 출력: "boolean"
console.log(typeof 42); // 출력: "number"
console.log(typeof "Hello"); // 출력: "string"
typeof operand // operand는 피연산자를 의미함
let x = 42;
let y = "Hello";
let z = {key: "value"};

console.log(typeof x); // 출력: "number"
console.log(typeof y); // 출력: "string"
console.log(typeof z); // 출력: "object"
let a;
console.log(typeof a); // 출력: "undefined"

console.log(typeof true); // 출력: "boolean"

console.log(typeof 42); // 출력: "number"

console.log(typeof "Hello"); // 출력: "string"

console.log(typeof {}); // 출력: "object"

console.log(typeof [1, 2, 4]); // 출력: "object"

console.log(typeof new Date()); // 출력: "object"

console.log(typeof null); // 출력: "object"

console.log(typeof function() {}); // 출력: "function"

console.log(typeof class C {}); // 출력: "function"

console.log(typeof Math.sin); // 출력: "function"

console.log(typeof Symbol("foo")); // 출력: "symbol"

console.log(typeof 123n); // 출력: "bigint"
console.log(typeof null); // 출력: "object"
let regex = /[a-zA-Z]/;
console.log(typeof regex); // 출력: "object"
const arr = [1, 2, 3];
console.log(Array.isArray(arr)); // true
// x를 선언한 적이 없음
console.log(typeof x); // "undefined"
/* 값이 할당되지 않은 변수 x */
let x;

if (x === undefined) {
    console.log("true로 평가됩니다.");
} else {
    console.log("false로 평가됩니다.");
}
// 출력: "true로 평가됩니다."

/* 선언되지 않은 변수 y */
try {
    y; // 변수에 접근 시도
    console.log('변수가 선언되었습니다.');

} catch (error) {
    console.log('변수가 선언되지 않았습니다.'); 
}
// 출력: "변수가 선언되지 않았습니다."
typeof 연산자의 브라우저 호환성
연산자
데스크탑 Chrome
Chrome
데스크탑데스크탑 Edge
Edge
데스크탑 Firefox
Firefox
Safari
Safari
typeof 1 12 1 1

caniuse.com에서 더 자세한 정보를 확인해 보세요.