3 ms·
But arr.foreach(elem => { ... }); is still always much slower than a for loop, having the callback call, isn't it?
by twsted 6y ago
But
arr.foreach(elem => { ... });
is still always much slower than a for loop, having the callback call, isn't it?
- DougBTX 6y agoThat very much depends on how good the JIT is, certainly many AOT compilers would understand this pattern and inline the callback, resulting in very similar optimised code.