undefined
次のような fancybox のように、パラメータとして持つ OSS ソース コード関数をよく見かけます。
(function (window, document, $, undefined) {
"use strict";
// snip-snip
}(window, document, jQuery));
;(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
これまたは何かにパフォーマンスの向上はありますか?