Chrome 无法进行数组解构

Chrome is unable to do array destructuring

我有以下功能:

function evaluateScroll(positions, width){
    var scale = width / (width - Math.abs(positions[0]) - Math.abs(positions[1]));
    var startLocation = positions[0] / width;

    return [scale, startLocation];
}

我按以下方式使用它:

[tscale, tstartLocation] = evaluateScroll(scrollPositions, scrollPlotWidth);

在 Safari 和 Firefox 中,它可以正常工作。然而,在 Chrome 中,代码在这一行挂起。

将其更改为:

var holder = evaluateScroll(scrollPositions, scrollPlotWidth);

有效,但我必须将 holder 的索引解析为适当的变量。

为什么 Chrome 不能使用数组式赋值?有没有我可以实现的语法,它适用于所有浏览器,而无需执行 holder 变量并重新分配给适当的变量?

看来chrome 48(当前稳定版)还不支持解构赋值语法:https://kangax.github.io/compat-table/es6/#destructuring

不过看起来 49 岁以上还是不错的!

我建议您使用 Babel 来编写现代 ES6/7 Javascript 代码。