Skip to content

前端最佳实践-类型检测

typeof

instanceof

constructor

js
const num = 1;
console.log(Object.getPrototypeOf(num).constructor === Number); // true

Object.prototype.toString