Loop Through an Object
In this example, you will learn to write a JavaScript program that will loop through an object.
To understand this example, you should have the knowledge of the following JavaScript programming topics:
JavaScript Objects
JavaScript for...in loop
Example 1: Loop Through Object Using for...in
In the above example, the for...in loop is used to loop through the student object.
The value of each key is accessed by using student[key].
Example 2: Loop Through Object Using Object.entries and for...of
The Object.entries() method returns an array of a given object's key/value pairs. The for...of loop is used to loop through an array.
Post a Comment