gpt4 book ai didi

javascript - WebStorm JavaScript 解构赋值

转载 作者:行者123 更新时间:2023-12-01 02:47:45 25 4
gpt4 key购买 nike

WebStorm 中以下有效的 ES6:

let {a,b} = {a:0,b:0};
{a,b} = {a:2,b:4};

在第二个等号处显示错误:“预期表达式”。显然 JavaScript 设置设置为 ES6。

顺便说一下,添加括号可以消除错误:

let {a,b} = {a:0,b:0};
({a,b} = {a:2,b:4});

这是一个错误还是 ES6 的一部分? Node 编译器似乎对第一个版本(没有括号)没有问题,因此它似乎不是标准的一部分。

最佳答案

这不是一个错误,这就是 ExpressionStatement是:

NOTE An ExpressionStatement cannot start with a U+007B (LEFT CURLY BRACKET) because that might make it ambiguous with a Block. An ExpressionStatement cannot start with the function or class keywords because that would make it ambiguous with a FunctionDeclaration, a GeneratorDeclaration, or a ClassDeclaration. An ExpressionStatement cannot start with async function because that would make it ambiguous with an AsyncFunctionDeclaration. An ExpressionStatement cannot start with the two token sequence let [ because that would make it ambiguous with a let LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.

关于javascript - WebStorm JavaScript 解构赋值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47159428/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com