JavaScript for in Array statement | Example code

  • by

JavaScript for in is used to loops through the properties of an object. This means a block of code inside the loop will be executed once for each property.


The syntax of the for…in the loop is:

for (variable in object)   

Example of JavaScript for…in array

HTML example code of for…in the loop through the properties of an object:

<!DOCTYPE html>

        const object = { a: 1, b: 2, c: 3 };

        for (const property in object) {
          console.log(`${property}: ${object[property]}`);




JavaScript for in Array statement

Do comment if you have another example or doubts or suggestions on this topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.