/
Iterate through Javascript object

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 content

Javascript Functions
Javascript Functions
More like this
DOM Element
DOM Element
Read with this
Javascript Object
Javascript Object
More like this
How can I reset the browser through Javascript?
How can I reset the browser through Javascript?
Read with this
Javascript Variables - Covering the core types
Javascript Variables - Covering the core types
More like this
DOM Elements versus HTML markup
DOM Elements versus HTML markup
Read with this