Skip to content

Instantly share code, notes, and snippets.

@junosuarez
Created October 7, 2013 21:48
Show Gist options
  • Save junosuarez/6875501 to your computer and use it in GitHub Desktop.
Save junosuarez/6875501 to your computer and use it in GitHub Desktop.
prototypal inheritance of getters / setters
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