DEV Community

Discussion on: Some awesome js tricks you should know about

tqbit profile image
tq-bit • Edited on

don't forget the invaluable method. Basically an abbreviation of array.forEach(), but executes a callback on each array element and returns an array with the mutated values.

const nums = [1, 15, 30];
const numsPlusTen = => num + 10);
console.log(numsPlusTen); // Returns [11, 25, 40]
Enter fullscreen mode Exit fullscreen mode
is_ellie profile image
Ellie Author

Haha right, .map() could basically do all forEach() could do, thanks for commenting btw!