Last active
March 5, 2017 17:17
-
-
Save GeoDoo/b8aaf2c53a1c567679184a88795d467c to your computer and use it in GitHub Desktop.
Prototype chains
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
var obj = { | |
prop: 1 | |
}; | |
console.log(obj.prop); // logs 1 | |
console.log(obj.prop2); // logs undefined | |
// If you want to delegate failed lookups to the prototype | |
// you use this technique | |
var obj2 = Object.create(obj); // this way the newly created object has access to the obj properties!!! | |
console.log(obj2.prop); // logs 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment