Map actually creates a new array. For each does not. this is the main difference.
on some machines, forEach() was more than 70% slower than map(). Your browser is probably different. You can check out the full test results here:
references:
https://codeburst.io/javascript-map-vs-foreach-f38111822c0f
No comments:
Post a Comment