var parent = {
name: 'Dad'
};
/* With ECMAScript 5, the prototypal inheritance pattern
formally entered the language via Object.create() */
var child = Object.create(parent)
console.log(child.name) // logs 'Dad'
var child = Object.create(parent, {
//notice the value designation, which is an ECMA5 descriptor
age: {value: 2}
});
console.log(child.age) // logs 2
console.log(child.hasOwnProperty('name')); // logs false
console.log(child.hasOwnProperty('age')); // logs true
Last active
June 11, 2017 22:51
-
-
Save awilson28/0402eeb3e46a5f585655 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment