Follow

(62/100)

that the convenience that one gets using `forEach` do not outweigh the performance lost.

In comparison the standard `for`-loop within performs the most(*) operations per second and `forEach` the least ([Source](jsbench.me/7ejagsewtr)). *: To squeeze even more performance one should cache the length of the array.

Further it should be considered to convert all other `for` operators like `for... in` or `for... of` to the standard `for`-loop.

Although these performance differences matter when iterating through larger numbers. Thus, one could argue on the smaller scale that the convenience makes sense. Though this could harden bad practices for the future.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.