【发布时间】:2020-09-29 12:27:41
【问题描述】:
今天,当我在编写代码时,在没有分号的对象定义的右大括号之后立即编写时,解构赋值将无法正常工作。
如果您看到相同的结果,请您从头开始重新创建此错误并报告。
我的节点版本是 12.16.2
我也在 Github 上报告了这个错误,用于 V8 引擎和 Nodejs
https://github.com/v8/v8.dev/issues/482#issue-711046361
https://github.com/nodejs/nodejs.org/issues/3411#issue-711047377
不带分号的对象的右大括号
let a,b,c
a={x:1} //<~~~without semicolon
[b, c] = [1, 2]
console.log(b)
console.log(c)
以上代码将返回
undefined
undefined
用分号定义的对象的大括号
let a,b,c
a={x:1}; //<~~~with semicolon
[b, c] = [1, 2]
console.log(b)
console.log(c)
以上代码将返回
1
2
if 语句的大括号
let a,b,c
if(1===1){
a = 1
} //<~~~without semicolon
[b, c] = [1, 2]
console.log(b)
console.log(c)
以上代码将返回
1
2
【问题讨论】:
标签: node.js compiler-errors v8