Sgraffite
Senior member
I see this all the time, but I've never understand the reason other than maybe habit? That's my only guess.
For example:
I could definitely be missing something, but I've always written it the latter way.
For example:
Code:
function Foo() {
var temp = 1;
function bar() {
console.log(temp);
}
function barPlusOne() {
console.log(temp + 1);
}
}
Code:
Foo.prototype = {
temp: 1,
bar: function(){
console.log(this.temp);
},
barPlusOne: function() {
console.log(this.temp + 1);
}
}
I could definitely be missing something, but I've always written it the latter way.