JavaScript for in is used to loops through the properties of an object. Means block of code inside the loop will be executed once for each property.
Syntax
The syntax of the for…in loop is:
1 2 |
for (<var>variable</var> in <var>object</var>) //statement |
Example of JavaScript for…in array
HTML example code of for…in Loop through the properties of an object:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!DOCTYPE html> <html> <head> <script> const object = { a: 1, b: 2, c: 3 }; for (const property in object) { console.log(`${property}: ${object[property]}`); } </script> </head> <body> </body> </html> |
Output:

Do comment if you have another example or doubts or suggestion on this topic.
Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version