loop attraverso l'elenco js
var arr = ["f", "o", "o", "b", "a", "r"];
for(var i in arr){
console.log(arr[i]);
}
scorrere l'elenco js
const array = ["one", "two", "three"]
array.forEach(function (item, index) {
console.log(item, index);
});
scorrere l'elenco javascript
const array = ["hello", "world"];
for (item of array) {
//DO THIS
}
JS scorrere un array
const beatles = [ "john", "paul", "ringo", "george"];
beatles.forEach((beatle) => {
console.log(beatle);
});
scorrere l'array in javascrpt
let array = [ 1, 2, 3, 4 ]; //Your array
for( let element of array ) {
//Now element takes the value of each of the elements of the array
//Do your stuff, for example...
console.log(element);
}
javascript modo migliore per scorrere l'array
[1,2,3,4,"df"].forEach((value, index) => console.log(index,value));
output
0 1
1 2
2 3
3 4
4 'df'