The for...in loop is used to loop through an object's properties.
Syntax
Here’s the syntax −
for (variablename in object){ statement or block to execute }
Example
Try the following example to implement ‘for-in’ loop. It prints the web browser’s Navigator object
Live Demo
<html> <body> <script> var aProperty; document.write("Navigator Object Properties<br /> "); for(aProperty in navigator) { document.write(aProperty); document.write("<br />"); } document.write ("Exiting from the loop!"); </script> </body> </html>