Boucle de l'attracture en javascript
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
arr.forEach(function(element){
console.log(element);
})
kinjal suryavanshi
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
arr.forEach(function(element){
console.log(element);
})
var items = ["item1", "item2", "item3"]
var copie = [];
items.forEach(function(item){
copie.push(item);
});
var counter = new Counter();
var numbers = [1, 2, 3];
var sum = 0;
numbers.forEach(function (e) {
sum += e;
this.increase();
}, counter);
console.log(sum); // 6
console.log(counter.current()); // 3
Code language: JavaScript (javascript)