Created
November 1, 2010 16:59
-
-
Save mklabs/658496 to your computer and use it in GitHub Desktop.
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
| // 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