为什么变异论证会导致无法优化?

时间:2017-12-16 09:31:44

标签: javascript node.js

bluebird article中,它说:

  

不得在任何地方传递或泄露arguments对象。

它有一些不好的例子如下:

function leaksArguments1() {
    return arguments;
}

function leaksArguments2() {
    var args = [].slice.call(arguments);
}

我无法理解为什么这会导致无法优化。感谢。

1 个答案:

答案 0 :(得分:2)

现代浏览器中的JavaScript解释器正在进行大量优化,如果arguments泄漏到函数之外,则会对其进行关闭。它在mdn documentation

中提到

enter image description here

我在这个问题here

中找到了完美的解释