Iterate through Javascript object

To iterate through a Javascript object you can use this syntax:

var CARinfo={ type :"Fiat", model:"500", color:"white" }; for (var Info in CARinfo) { console.log(Info, CARinfo[Info]); }

This would give the following output at the Javascript console:

 

Related pages