#55 Destructuring and Default Values

Tip

Not really an ember tip but since ember uses ES2015 by default, it is somewhat related.

One of my favorite features in ES2015 (ES6) is object destructuring.  Imagine this code.

You can write the same code with:

c will be assigned 3 if it does not exist in obj.  There is a lot more to object and array destructuring – see links below for more tips.

Credits & Links

http://www.2ality.com/2015/01/es6-destructuring.html
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
For an ember related use case, see http://balinterdi.com/2016/08/11/using-dependency-injection-to-write-better-tests.html

Free Programming Books and lifetime access to IconApp.io

I am giving away some programming books and lifetime access to iconapp.io library of awesome icons.  Check it out at https://gleam.io/XqHjW/rock-and-roll-with-emberjs

Share A Tip

Let us know if you have a good ember tip (you will get full credit)
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 how I can improve them.

Published by

Emad Ibrahim

Author of asp .net MVC & TDD, entrepreneur, passionate technologist, programmer and productivity nut. more at http://t.co/oSJXPvzu