Iterating over objects

Lo-Dash has a few functions that are useful when we need to iterate over the properties of an object in order to fulfill the behavior of our component. We'll start off by exploring some basic iterations. Then, we'll look at how to iterate over inherited object properties, followed by looking at keys and values and simple approaches to iterating over them.

Basic For Each

Just as we saw in the previous chapter, objects can be iterated, just as arrays—they're both collections. While the mechanism to do so is slightly different, Lo-Dash abstracts those differences away behind a unified function API, as shown in the following code:

var object = { name: 'Vince', age: 42, occupation: 'Architect' }, result = []; _.forOwn(object, function(value, ...

Get Lo-Dash Essentials 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.