0

undefined次のような fancybox のように、パラメータとして持つ OSS ソース コード関数をよく見かけます。

(function (window, document, $, undefined) {
    "use strict";
    // snip-snip
}(window, document, jQuery));

またはこれから jquery validate

;(function(defaults, $, undefined) {
   // snip, snip
})({
   // snip, snip settings
}, jQuery);

何か理由があるのでしょうか?


編集:さて、ローカルで定義されていない未定義になることがわかりましたが、これに問題があり、何かをチェックするundefinedとうまくいかないことがあります:

if (thing === undefined) {} 
    // will crash if thing has never been initialized

if (typeof thing === 'undefined') {} 
    // always works

これまたは何かにパフォーマンスの向上はありますか?

4

0 に答える 0