核心知识
typeof 与类型观察
typeof 返回一个表示类型的字符串,可辅助理解表达式。
- typeof 42 是 number
- typeof '42' 是 string
- typeof null 历史上返回 object,需要单独判断
typeof 42; // 'number'
typeof '42'; // 'string'
value === null; // 判断 null
typeof 返回一个表示类型的字符串,可辅助理解表达式。
typeof 42; // 'number'
typeof '42'; // 'string'
value === null; // 判断 null