Book Image

Lo-Dash Essentials

By : Adam Boduch
Book Image

Lo-Dash Essentials

By: Adam Boduch

Overview of this book

Table of Contents (15 chapters)
Lo-Dash Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Assigning and accessing properties


Creating new JavaScript objects with values assigned to them is a straightforward task. The tedious part is when we have to merge the contents of one object into another or when we have to ensure that the default values are populated for the new objects. Locating values in objects and validating whether a key exists or not would actually require a significant amount of code were it not for the Lo-Dash tools that help us with these activities.

Extending objects

A common pattern in JavaScript libraries is to extend objects with other objects to assign property values. This can be done by assigning one property to an object on a statement-by-statement basis. The trouble with this approach is that you need to know ahead of time, exactly, which properties are going to be assigned to the destination object. Consider when new values come from a function argument. Having to know ahead of time all the possible properties these argument values might have isn't feasible...