Here is the code and fiddle:
var test = {
value : "sss",
func1 : function(){
console.log(this.value);
}
};
var test2 = function(){
return {
value : "sss",
func1 : function(){
console.log(this.value);
}
};
}();
test.func1();
test2.func1();
Hey lads, what's the difference between these two ways of method calling. I have to make test2 as Inmmediate Invoke Function Execution to make sure it works. Does it mean carry coals to Newcastle? Which one is better or what situation should I use them?