More Related Content
Similar to JavaScript 闭包分享(一):传递参数 (20)
JavaScript 闭包分享(一):传递参数
- 4. 常见结构:表达式(缓存示例) var get = function() { var cache = {}; return function(selector) { if(cache.hasOwnProperty(selector)) return selector.cache; return cache.selector = D.query(selector); }; }();
- 7. 回顾: (function() { // your code... })(); (function($) { $(function() { // code on DOMReady… }); })(jQuery);
- 8. 传递常见引用:示例 (function(w, d) { // w.setTimeout(… // d.getElementById(… })(window, document); (function(win, doc) { // win.setTimeout(… // doc.getElementById(… })(window, document);