Answers for "how to loop through the list in javascript"

72

javascript code to loop through array

var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}
Posted by: Guest on July-22-2019
13

loop through list js

var arr = ["f", "o", "o", "b", "a", "r"]; 
for(var i in arr){
	console.log(arr[i]);
}
Posted by: Guest on November-12-2021
8

iterate through list js

const array = ["one", "two", "three"]
array.forEach(function (item, index) {
  console.log(item, index);
});
Posted by: Guest on May-31-2020
2

javascript best way to loop through array

var len = arr.length;
while (len--) {
    // blah blah
}
Posted by: Guest on March-25-2020

Code answers related to "how to loop through the list in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language