Foreach in javascript
If you wanna use foreach to loop through an array (list) in javascript, do as the following example:
var myarray = ["genius", "super", "god"];
myarray.forEach(function(value, index){
console.log(index + ": " + value);
});
the result will be:
0: genius
1: super
2: god
Tested in Chrome 45.
var myarray = ["genius", "super", "god"];
myarray.forEach(function(value, index){
console.log(index + ": " + value);
});
the result will be:
0: genius
1: super
2: god
Tested in Chrome 45.