0
forEach() in Javascript,, how can we use ? This function
Anybody can tell me ?? And what is benefit of this function
2 Réponses
+ 4
Benefit: shorter than for loop.
const arr = [2, 3, 7, 8];
arr.forEach(v => {
console.log(v * 2);
});
+ 1
Another benefit: no fiddling with indices and easier to read and understand