The for-in statement is used to return a property or properties of an object.

The syntax looks like this:

for (property in expression) {



Or in the real example with real values:

var prop;

var person={firstname:"John",lastname:"Doe",age:105};

for (prop in person) {



Therefore, the variable prop will represent one property of the person object in each loop. The next loop call will shift the pointer to the next property in the object, till all of them are enumerated.


The example with for-in statement in JavaScript:


›› go to examples ››