javascript 为啥不用instanceof检测数组,这里有一个示例坑

https://www.cnblogs.com/laiqun/p/5645801.html

注意:其文章中说 instanceof 是 constructor 的语法糖,是有待斟酌的:

function Person () {}
Person.prototype = {
  name: 'Jim', 
  age: '21'
}
                                                    
var person = new Person()
console.log(person instanceof Person)    //true
console.log(person.constructor === Person)    //false

猜你喜欢

转载自blog.csdn.net/lishk314/article/details/83822823