The for :for loop has no additional function call stack and context, so its implementation is the simplest.
ForEach: For ForEach, its function signature looks like this.
It contains parameters and context, which affects its performance this time.
Map :map is the slowest because it will return a new array. The creation and assignment of the array will lead to the allocation of memory space and bring more performance overhead. If the mapping is nested in a loop, it will bring more unnecessary memory consumption.
Simply put:
When your loop doesn't need to return a value (it shouldn't) or change data (although callback changes are allowed), for example, you just want to do something with this traversal, then you can choose foreach.
When you need to change data values or chain calls, then use map.
Although the map can really achieve some operations you want, such as:
In fact, it is more suitable for fore or forEach.
As described in MDN, Array.prototype.map ():
So in today's eslint, try not to ignore any hints.