loading...

re: Don’t use for loop for JavaScript Arrays VIEW POST

TOP OF THREAD FULL DISCUSSION
re: You can easily get the performace metic on online b/w for and other functions . And every thing has pro and cons . I also has used for loop insted ...

Oh, you mean those tests in which if you place forEach before for then forEach becomes faster? The same tests in which if you actually use the result of the operation afterwards map becomes faster than for?

"Because performance" doesn't seem a particularly good argument to choose one option over another. How fast a for, map, etc will run depends on more than its name, like optimisations that the runtime can do. So just choosr whichever fits your needs and if you run into performance issues profile and see what's causing the bottleneck (which probably won't be that map that you chose to use instead of a for loop).

Yes! This is what I mean. Engineers should consider performance when deciding which method to use.

Some comments have been hidden by the post's author - find out more

code of conduct - report abuse