Reputation: 6508
What does this construct mean?
var digits = [1, 2, 3];
(function fetchData(name){
//body
})(digits.shift());
Upvotes: 1
Views: 357
Reputation: 28554
That syntax is used to prevent identifiers from leaking into the containing namespace.
After that code, if you attempt to call fetchData(name)
you will find that fetchData
is undefined, thanks to the () wrapper.
Upvotes: 2
Reputation: 8240
Declare a function and call it.
Click on this http://jsfiddle.net/TC8K6/ you will see a alert of the parameter passed to the function.
Upvotes: 1
Reputation: 10429
which construct?
I can explain what's happening, if that will help:
(in the order of execution)
Upvotes: 2