简体   繁体   English

JavaScript中的匿名数组分配

[英]Anonymous array assignment in javascript

Firefox (v 16) has no problem with this anonymous array assignment from a function: Firefox(v 16)对此函数的匿名数组分配没有问题:

var x = 0; var y = 0;
[x,y] = incr1(x,y);  // x,y now both equal 1
function incr1(x,y) {
    return [x+1,y+1];
}

using the developer tools in Chrome (v 18) on the other, it hand complains "Uncaught reference error: invalid left hand side in assignment" 另一方面,使用Chrome(v 18)中的开发人员工具时,它抱怨“未捕获的参考错误:分配中的左手无效”

Firefox是唯一支持该语法的浏览器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM