var proto = Object.prototype;
var hasOwnProp = proto.hasOwnProperty;
var dog = {
pet: true
};
var labrador = Object.create(dog);
labrador.watchdog=true;
console.log(hasOwnProp.call(labrador, "watchdog"));
console.log(labrador.hasOwnProperty("watchdog"));
function hasOwn(o, prop) {
return hasOwnProp.call(o, prop);
}
console.log(hasOwn(dog, "pet"));
Output:
true true true
No comments:
Post a Comment