Skip to content

Instantly share code, notes, and snippets.

@GeoDoo
Last active March 5, 2017 17:17
Show Gist options
  • Save GeoDoo/b8aaf2c53a1c567679184a88795d467c to your computer and use it in GitHub Desktop.
Save GeoDoo/b8aaf2c53a1c567679184a88795d467c to your computer and use it in GitHub Desktop.
Prototype chains
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