自己做的网站如何上百度,怎么把源码做网站,网站建设公司问候语,制作一个网址需要多少钱1 typeof用于检测基本数据类型#xff0c; 原理机制、采用的是计算机底层存储二进制检测#xff0c;效率比较快。 null在计算机存储二进制的过程中是64个零#xff0c;而typeof判断的话前三位都为0的时候是object。 typeof只能检测基本数据类型1 typeof用于检测基本数据类型 原理机制、采用的是计算机底层存储二进制检测效率比较快。 null在计算机存储二进制的过程中是64个零而typeof判断的话前三位都为0的时候是object。 typeof只能检测基本数据类型 在检测Array Object null 返回值都是object。 2 instanceof 用于检测对象类型无法准确区分object array 检测基本数据类型 返回的结果是 false 1 instanceof Number // false new Array(1) instanceof Number // true arr instanceof Array // true arr instanceof object // true object instanceof object // true object instanceof Array // false 3 constructor 用于构造函数原型的constructor指向构造函数本身来辨别的 console.log([].constructor Array) VM7631:1 true console.log({}.constructor Object) VM7756:1 true console.log(1.constructor Number) VM7756:1 false
4 object.prototype.tostring.call(value) 内置构造函数的原型对象上基本上都有tostring这个方法 只要把object.prototype.tostring执行方法中的this是谁检测结果就是谁【object ?】 console.log(Object.prototype.toString.call(1)) VM8801:1 [object String] console.log(Object.prototype.toString.call(1)) VM8932:1 [object Number] console.log(Object.prototype.toString.call([])) VM9063:1 [object Array] console.log(Object.prototype.toString.call({})) VM9082:1 [object Object] console.log(Object.prototype.toString.call(null)) VM9237:1 [object Null]