Lesson 10. Object.assign

After reading lesson 10, you will

  • Know how to set default values with Object.assign
  • Know how to extend objects with Object.assign
  • Know how to prevent mutations when using Object.assign
  • Understand how Object.assign assigns values

Libraries like Underscore.js and Lodash.js have become like the utility belts of JavaScript. They add solutions to common tasks so that the average developer doesn’t need to reinvent the wheel for every project. Some of these tasks become so ubiquitous and well-defined that it makes sense to actually include them in the language. Object.assign is one such method. With it you can easily set default values or extend objects in place or as copies, all without having to write a lot of boilerplate ...

Get Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.