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.
- JavaScript functions
- Event (Event) in JavaScript
- Page navigation (Redirect) in JavaScript
- Dialogs - Alert, Prompt, Confirmation in JavaScript
- Void keywords in JavaScript
- Print pages in JavaScript
- Objects in JavaScript
- Tutorial for creating slideshows in JavaScript with 3 easy steps
- 7 Framework JavaScript for mobile application development
- Introduction to 2D Array - 2-dimensional array in JavaScript
- 12 extremely useful tricks for JavaScript programmers
- Arrays and objects in JavaScript are like stories and newspapers!