• RSS Unknown Feed

    • An error has occurred; the feed is probably down. Try again later.
  • Meta

JavaScript: Enumerating Properties of an Object with a For/In Loop

JavaScript object properties can be enumerated by using a for/in loop, as demonstrated below:

var objCar = new Object();
objCar.wheels = 4;
objCar.tires = 4;
objCar.engines = 1;

for (var i in objCar)
{
document.write(i);
document.write('<br/>');
}

The result of this code is:

wheels
tires
engines

Leave a comment