Created
July 18, 2018 18:18
-
-
Save sevperez/e1c08d73041fb4c079fea388567a46f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// prototypes3.js | |
var House = { | |
ringDoorbell: function() { | |
console.log("ding dong!"); | |
}, | |
describe: function() { | |
console.log(this.owner + "'s house has " + this.rooms + " rooms."); | |
} | |
}; | |
var bobsHouse = Object.create(House); | |
bobsHouse.owner = "Bob Belcher"; | |
bobsHouse.rooms = 4; | |
console.log(Object.getOwnPropertyNames(bobsHouse)); | |
// Logs: ["owner", "rooms"] | |
console.log(bobsHouse.hasOwnProperty("rooms")); | |
// Logs: true | |
console.log(bobsHouse.hasOwnProperty("ringDoorbell")); | |
// Logs: false | |
console.log(Object.getPrototypeOf(bobsHouse).hasOwnProperty("ringDoorbell")); | |
// Logs: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment