首先说明,这个题非常考验你对原型链的认识程度
实验的两个对象:obj1=[1];obj2={name:"jack"}
第一种方法:使用Object.getPrototypeOf函数
console.log(Object.getPrototypeOf(obj1)==Array.prototype,
Object.getPrototypeOf(obj2)==Array.prototype)
返回 true和false
第二种方法:使用father.isPrototypeOf(child)函数
console.log(Array.prototype.isPrototypeOf(obj1))
返回 true和falseconsole.log(Array.prototype.isPrototypeOf(obj2))
第三种方法:使用obj.constructor
console.log(obj1.constructor==Array)
返回 true和falseconsole.log(obj2.constructor==Array)
第四种方法:使用instanceof