3

If this operator declared:

const { assign, isEmpty, run } = Ember;

Then, instead of:

Ember.run(() => { ... });
Ember.assign(foo, {});

It can be written as:

run(() => { ... });
assign(foo, {});

Which is much nicer!

What is it and how does it work?

Note: I'll edit this question to make it clearer when I know...

Rimian
  • 32,654
  • 13
  • 106
  • 109
  • It's called [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) – Rob M. Aug 23 '17 at 01:00

1 Answers1

4

It's called destructuring and yes, it's very nice. Very convenient for cleaning up your code.

As explained by 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.

Full reference here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Christopher Messer
  • 1,840
  • 5
  • 11