Created
February 28, 2017 02:20
-
-
Save egrueter-dev/a688f07fbe55cbf54a2134f8955d8ed6 to your computer and use it in GitHub Desktop.
prototypechain2
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
// 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