For ... loop in JavaScript
The for ... in loop is used to iterate over the properties of an object. When we haven't discussed the object yet, you may not feel comfortable with this loop. But once you understand how objects work in JavaScript, you will find this loop very useful.
The for . in loop is used to iterate over the properties of an object. When we haven't discussed the object yet, you may not feel comfortable with this loop. But once you understand how objects work in JavaScript, you will find this loop very useful.
Syntax
for ( variablename in object ){ statement or block to execute }
In each iteration, an attribute from the object - the object is assigned to variablename - the variable name and this loop continue until all properties of the object are gone.
For example
You try the following example of a for . in loop. It prints the Navigator object of the web browser.