【发布时间】:2019-07-12 13:37:00
【问题描述】:
根据 javascript.info,下面的代码应该可以工作, https://javascript.info/destructuring-assignment#object-destructuring
在我的项目中,我已经定义了一些变量,现在我正在尝试使用 destructuring 分配一个值
但是,我无法在下面的代码中运行。
// This also does not work.
let title, width, height;
myobj = {title: "Menu", width: 200, height: 100}
({title, width, height}) = myobj;
console.log(title);
// This also does not work.
let title, width, height;
myobj = {title: "Menu", width: 200, height: 100}
{title, width, height} = myobj;
console.log(title);
【问题讨论】:
标签: javascript object destructuring