We have few techniques to iterate over the arrays, objects and strings.
Tested the each technique with 1 Million iterations and executed the test.js
file for 5
times using the for i in {1..5}; node test.js;
command.
While
loop - 1.4msDo while
loop - 0.8msFor
loop - 0.8msFor Of
loop - 9.5msFor In
loop - 137msMap
method - 8.5msFilter
method - 7.2msReduce
method - 6.4msSort
method - 11.7msEvery
method - 7.2msSome
method - 6.8msChaining methods
- 16.3ms