Take a look at this code:
That’s a lot of typing, we can refactor this into:
So that’s more readable but now comes the actual tip, we can set age, firstName, lastName in one call using getProperties and our code would look like this:
Note that getProperties returns an object and we are just using destructuring assignment to set the variables. so
var myObj = this.getProperties('age', 'firstName', 'lastName');
will create an object myObj with 3 properties named named age, firstName, lastName.
PS: there is also setProperties which you can use to mass assign.
Credits & Links
Ember.Object.getProperties @ http://emberjs.com/api/classes/Ember.Object.html#method_getProperties
Some Love ❤❤❤
If you are enjoying my daily tips please spread the word with this one-click tweet.
If you do NOT like the tips then please reply to this email and let me know.