Skip to content

Instantly share code, notes, and snippets.

@mklabs
Created November 1, 2010 16:59
Show Gist options
  • Select an option

  • Save mklabs/658496 to your computer and use it in GitHub Desktop.

Select an option

Save mklabs/658496 to your computer and use it in GitHub Desktop.
// override the bar prop for foo w/o affecting bim
foo.bar = 'new value';
// change the bar prop for both foo and bim
// (*if* it hasn't been overridden locally!)
Thinger.prototype.bar = 'another new value';
// we could delete foo.bar now and it would get
// the prototype value instead
// delete foo.bar;
// add a method to foo and bim to log bar
Thinger.prototype.logger = function() {
console.log(this.bar);
};
// check if bar has been overridden
foo.hasOwnProperty('bar'); // true
bim.hasOwnProperty('bar'); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment