Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

javascript loop through array

var data = [1, 2, 3, 4, 5, 6];

// traditional for loop
for(let i=0; i<=data.length; i++) {
  console.log(data[i])  // 1 2 3 4 5 6
}

// using for...of
for(let i of data) {
	console.log(i) // 1 2 3 4 5 6
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #loop #array
ADD COMMENT
Topic
Name
7+6 =