0

forEach() in Javascript,, how can we use ? This function

Anybody can tell me ?? And what is benefit of this function

26th Jan 2021, 3:53 PM
Sajid Ali
Sajid Ali - avatar
2 odpowiedzi
+ 4
Benefit: shorter than for loop. const arr = [2, 3, 7, 8]; arr.forEach(v => { console.log(v * 2); });
26th Jan 2021, 4:04 PM
JaScript
JaScript - avatar
+ 1
Another benefit: no fiddling with indices and easier to read and understand
26th Jan 2021, 5:02 PM
Benjamin Jürgens
Benjamin Jürgens - avatar