Created
June 30, 2011 20:40
-
-
Save jeremyroman/1057181 to your computer and use it in GitHub Desktop.
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
var f = function() {}; | |
f.prototype.food = { apples: 0, bananas: 0 }; | |
var f1 = new f(); | |
f1.food.apples++; | |
var f2 = new f(); | |
console.log(f2.food.apples); // 1 | |
This is because the food object is modified in-place, and both instances refer to the same object. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment