※ 本文為 dinos.bbs. 轉寄自 ptt.cc 更新時間: 2012-07-16 09:53:07
看板 Ajax
作者 標題 Re: [問題] (...)()或(...)(window)是什麼意思?
時間 Mon Jul 16 09:48:30 2012
※ 引述《kilva (嗡嗡)》之銘言:
: 這裡有個問題。下法兩種寫法
: var temp = function(window) {
: // 程式碼
: }(window);
: 和
: (function(window){
: // 程式碼
: })(window); // 或 }(window));
: 之間在沒有return的情形之下,除了會多出一個值為undefined的變數之外,
: 還有什麼其他不同的地方嗎?
http://www.atlanticbt.com/blog/create-your-own-javascript-library/
Create your own Javascript Library | Atlantic BT
We all know about the performance benefits of putting all of our javascript/jQuery calls into .js files, so that browsers will cache the whole chunk on the client-side. It's even more tempting to put all of our complicated jQuery calls into a single file, thus further enhancing performance by reduci ...
We all know about the performance benefits of putting all of our javascript/jQuery calls into .js files, so that browsers will cache the whole chunk on the client-side. It's even more tempting to put all of our complicated jQuery calls into a single file, thus further enhancing performance by reduci ...
可以封裝起來當作library呼叫
var animal = function(window) {
var name = 'tom';
var API = {
"getName": function(){ return name;}
};
return API;
}(windows);
animal.getName();
--
http://blog.carlcarl.tw
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.127.237.167
--
※ 同主題文章:
07-14 00:28 ■ Re: [問題] (...)()或(...)(window)是什麼意思?
07-14 00:56 ■ Re: [問題] (...)()或(...)(window)是什麼意思?
● 07-16 09:48 ■ Re: [問題] (...)()或(...)(window)是什麼意思?
※ 看板: dinos 文章推薦值: 0 目前人氣: 0 累積人氣: 67
回列表(←)
分享