Please somebody help me out and explain the difference between:

for(var i in temp){
		this["get" + i] = function(){return i;}
}

and

for(var i in temp){
       (function(){
		this["get" + i] = function(){return i;}
       })();
}

Thanks in adv

A useful reply can be provided only when we set a proper context here. Read the closure notes.

Now, what do you think those two do? What differences do you see in them? Do they end up solving the problem at hand?

Hint: Both approaches don't do what they were intended to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.