In my own projects, I use linting rules like unicorn/no-array-for-each
due to the minor performance cost associated with using .forEach
compared to for..of
.
While reviewing the Babylon.js source code, specifically in assetContainer.ts
, I noticed that .forEach
is frequently used for traversing arrays. Is there a specific reason for this choice?
For reference, here is a benchmarking comparison of .forEach
vs for..of
: https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_of/.
I’d love to understand the reasoning behind this design decision. Is it for readability, consistency, or something else?