IIFE Parameters vs Declaration

时间:2019-03-05 16:40:12

标签: javascript

Are there reasons for creating variables as undefined parameters instead of declaring them using var or let?

(function (a, b, c, d, e) {
     c = b.createEleement('a');
     d = b.getElementsByTagName('div');
     e = a.outerWidth;
})(window, document)


(function (a, b) {
    var c = b.createEleement('a'),
        d = b.getElementsByTagName('div'),
        e = a.outerWidth;
})(window, document)

1 个答案:

答案 0 :(得分:2)

这是minifiers用来保存var关键字的一种技术,如果已经有IIFE。

没有充分的理由编写这样的源代码,这很令人困惑。