Devacron.com

How to loop through javascript object. The easy way!

Under ECMAScript 5, you can combine Object.keys() and Array.prototype.forEach()

var obj = { first: "Chris", second: "Maria", third: "Alex" };
Object.keys(obj).forEach(function(key) { console.log(key, obj[key]); });

More details: Object.keysArray.prototype.forEach.

Exit mobile version