我有以下功能:
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+ 就很好了!
关于javascript - Chrome 无法进行数组解构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35234689/