loop elements in javascript
var colors=["red","blue","green"];
for (let i = 0; i < colors.length; i++) {
console.log(colors[i]);
}var list = [{a:1,b:2}, {a:3,b:5}, {a:8,b:2}, {a:4,b:1}, {a:0,b:8}];
for (var i = list.length - 1, item; item = list[i]; i--) {
console.log("Looping: index ", i, "item", item);
}
######### ES6 Update ################
for (let item of list) {
console.log("Looping: index ", "Sorry!!!", "item" + item);
}
Also in JavaScript:
- get params js
- The missing value javascript
- Can't bind to 'ngForOf' since it isn't a known property of 'th'
- javascript switch range
- renemane object key js
- Javascript program printing the lyrics to the 99 bottles of beer song web
- how to animate array oy react elements
- diameter of binary tree javascript
- chart js radar grid color
- anagram program in javascript
- .index of javascript
- cypress memory leak
- random light color js
- react template
- check if even or odd javascript
- merge sort javascript
- javascript how to get subarray
- set kacgground image js
- javascript set header text
- clone aJavaScript object
- clear cookies js
- for loop inside a for loop javascript
- append a method to an already existing class in javascript
- swap elements in array javascript