Skip to content

Instantly share code, notes, and snippets.

@takempf
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save takempf/8866658 to your computer and use it in GitHub Desktop.

Select an option

Save takempf/8866658 to your computer and use it in GitHub Desktop.
// Thing constructor
var Thing = function(){
this.pies = ['cherry','apple'];
};
Thing.prototype = {};
Object.defineProperties( Thing.prototype, {
piescount: {
get: function(){ return this.pies.length; }
}
});
// Use Thing
var thing = new Thing;
thing.piescount === 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment