Iterating Objects

Background

In this lesson, we see how loops iterate objects.

Objects recap

Objects are an unordered collection of data where each data item is a value referenced by a key (property name). To access each data item in an object, the property name is used to refer to that value.

Iterating objects

To access a data item in an object, use its key (property name). To access all values, we need to use a list of keys.

Object methods

Take a look at some of the object’s methods that will help us iterate an object.

Object.keys

The Object.keys method gives an array of keys for a certain object. The following code shows this method in action.

Get hands-on with 1400+ tech skills courses.