可以使用hasOwnProperty()
或in
操作符
let obj = {
name:'flten'
}
let newObj = Object.create(obj, {
age :{
enumerable:true,
configurable:true,
writable:true,
value:16,
}
})
console.log(newObj.hasOwnProperty('name')) // false
console.log('age' in newObj) // true
function Animal(){}
function Dog(){}
Dog.prototype = Object.create(Animal.prototype)
let dog = new Dog()
console.log(dog instanceof Animal) // true
console.log(dog instanceof Object) // true