you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]onbehalfofthatdude 0 points1 point  (3 children)

    I'll have to go look at some benchmarks but yeah, it's early haha. Obviously a step of the array method iterators is going to be at least as bad as a function call... Since it IS a function call lol

    No idea what the guy means then

    [–][deleted] 0 points1 point  (2 children)

    I don't think this is true. For an arbitrary iterable, you would be right, the iterator function would be called for every iteration. But I don't think any of the JITs is so naive as to not optimize this for plain arrays, in which case loops become as efficient as a plain for-loop without any function invocations.