这个问题已经在这里有了答案: > Javascript object bracket notation ({ Navigation } =) on left side of assign 4个
如果此运算符声明:
const {Assign,isEmpty,run} = Ember;
然后,代替:
Ember.run(() => { ... });
Ember.assign(foo, {});
它可以写成:
run(() => { ... });
assign(foo, {});
哪个更好!
它是什么以及它如何工作?
注意:当我知道…时,我将编辑此问题以使其更清楚.
解决方法:
这叫做解构,是的,非常好.清理代码非常方便.
如MDN所述:
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
此处完整引用:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment