Tip 30 Simplify Key-Value Assignment

In this tip, you’ll learn how to make objects quickly with shortened key-value assignment.

You just learned how to pull apart objects in a clear and clean way. Now that you have all those pieces laying out on your proverbial work bench, you need to put them back together. It wouldn’t be any good if the writers of the spec gave you a clean interface to take objects apart while leaving you no way to put them back together.

Well, you’re in luck. The same technique you’d use to take objects apart works in reverse. It’s time to build new objects using similar syntax that will leave your code clear and predictable.

Start with a similar object of photo information:

​  ...

Get Simplifying JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.