可能重複:
What does this mean? (function (x,y)){…}){a,b); in JavaScript
What do parentheses surrounding a JavaScript object/function/class declaration mean?這是什麼「(function(){});」,括號內的函數,意味着在JavaScript中?
大家好
我不知道以下哪些呢:
(function(){
// Do something here
...
})(someWord) //Why is this here?;
我闕是:
- 將一個函數放在括號中的含義.i.e。
(function(){});
? - 一組括號在函數結尾做了什麼?
我通常在jQuery代碼和其他一些JavaScript庫中看到這些。
這裏同樣的問題:http://stackoverflow.com/questions/3921922/what-does-this-mean-function-xyab- in-javascript/3921997#3921997 – DoXicK 2010-10-28 14:14:19