1、数据类型检测 typeof 无法准确检测引用类型;instanceof 无法检测基本数据类型,且只要是在原型链上出现过构造函数都会返回true; 所以,使用 Object.prototype.toString.call() function getType (value) { const str = Object.prototype.toString.call(value); return str.slice(8, -1); } getTy...
1、数据类型检测 typeof 无法准确检测引用类型;instanceof 无法检测基本数据类型,且只要是在原型链上出现过构造函数都会返回true; 所以,使用 Object.prototype.toString.call() function getType (value) { const str = Object.prototype.toString.call(value); return str.slice(8, -1); } getTy...