Skip to content

Instantly share code, notes, and snippets.

@egrueter-dev
Created February 28, 2017 02:20
Show Gist options
  • Save egrueter-dev/a688f07fbe55cbf54a2134f8955d8ed6 to your computer and use it in GitHub Desktop.
Save egrueter-dev/a688f07fbe55cbf54a2134f8955d8ed6 to your computer and use it in GitHub Desktop.
prototypechain2
// Creating the second prototype
const proto2 = function () {};
proto2.prop3 = "proto 2's property"
// Creating the first prototype
const proto1 = Object.create(proto2)
proto1.prop2 = 'protos property';
const obj = Object.create(proto1);
obj.prop = 'object\'s property';
console.log(obj.prop); //=> 'object's property'
console.log(obj.prop2); //=> 'proto's property'
console.log(obj.prop3); //=> 'proto2 property'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment