타입 종류

typeof 연산자

typeof "string"; // string
typeof false; // boolean
typeof 1; // number
typeof undefined; // undefined
typeof null // obejct
typeof Symbol(); // symbol
typeof new String(123); // object
typeof function func() {}; // function
typeof class MyClass {}; // function

instanceof 연산자

function func() {};
const array = [];
const date = new Date();

func instanceof Function // true
arr instanceof Array // true
date instanceof Date // true

func instanceof Obejct// true
arr instanceof Obejct// true
date instanceof Obejct// true

Object.prototype.toString.call(func) // [Obejct Function]
Object.prototype.toString.call(arr) // [Obejct Array]
Object.prototype.toString.call(date) // [Obejct Date]
Object.prototype.toString.call(new String(123)) // [Obejct String]

타입 검사는 주의를 기울이며 해야한다.