Last active
December 15, 2015 04:39
-
-
Save jackfranklin/5203503 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
var Basket = function() { | |
this.count = 5; | |
}; | |
Basket.prototype.count = 1; | |
var x = new Basket(); | |
console.log(x.count); // 1 or 5? (and why?) | |
// and | |
var Basket = function() {}; | |
Basket.prototype.count = 1; | |
var x = new Basket(); | |
x.count = 5; | |
console.log(x.count); // 1 or 5? (and why?) |
Sorry for the confusion @chinchang @mrappleton - I made a mistake in my example facepalm. The second example was wrong - as you point out setting Basket.count
doesn't really do much of value. Updated it now.
haha. I was wondering how come I wrote the second O/P wrong :P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mrappleton Ahh...my bad :) you are right.