Created
October 7, 2013 21:48
-
-
Save junosuarez/6875501 to your computer and use it in GitHub Desktop.
prototypal inheritance of getters / setters
This file contains 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
a = Object.create({}, { | |
foo: { | |
get: function () { console.log('a.foo get') }, | |
set: function (val) { console.log('a.foo set:', val) } | |
} | |
}) | |
function B(){} | |
B.prototype = a | |
var b = new B | |
b.foo = 12 | |
console.log(b.foo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment