How To Iterate Over Arrays And Objects In Javascript
var points = [{ x: 75, y: 25},{ x: 75+0.0046, y: 25}]; How would I iterate through this. I want to print x and y value first, then 2nd and soo on....
Solution 1:
var points = [{ x: 75, y: 25},{ x: 75+0.0046, y: 25}];
//ES5
points.forEach(function(point){ console.log("x: " + point.x + " y: " + point.y) })
//ES6
points.forEach(point=>console.log("x: " + point.x + " y: " + point.y) )
Post a Comment for "How To Iterate Over Arrays And Objects In Javascript"