var points = [{ x: 75, y: 25},{ x: 75+0.0046, y: 25}];
How would I try this. I want to print the values โโof x and y first, then the 2nd and soo on ....
Use the Array#forEach method to iterate through the array.
Array#forEach
var points = [{ x: 75, y: 25 }, { x: 75 + 0.0046, y: 25 }]; points.forEach(function(obj) { console.log(obj.x, obj.y); })
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) )
You can use the for..of .
for..of
var points = [{ x: 75, y: 25},{ x: 75+0.0046, y: 25}]; for (let point of points) { console.log(point.x, point.y); }
Source: https://habr.com/ru/post/1259262/More articles:.NET Core Entity Framework Stored Procedures - c #Import an existing C ++ library (.a or .so file) ndk android - androidC / C ++ with Android Studio version 2.2 - c ++Incorrect "login" route configuration: one of the following conditions must be provided (component or redirectTo or children or loadChildren) - angularUse libusb1.0.so functions inside your own library - c ++NewtonSoft not found - c #Create settings menu with custom action bar / toolbar - androidAsible, how to add a user to a group only if the user exists - dockerWhy does my inner loop only work once? - cHow to change HTTP response body using Charles Proxy rewriting tool and regex? - jsonAll Articles