NodeJS is not magic, and you are not a Wizard
Ivan Seidel Gomes
603

I do not agree with your conclusion

DO NOT USE OBJECTS AS ARRAYS, NODEJS WILL HATE YOU FOR THAT.

Your first 2 tests measured a lot of noise and are not valid. (See my 2 previous comments). The third test is not a surprise and the result that you got is the expected one. Array result is slow, because on every insert `indexOf()` is called and it has a complexity of O(N). Object result is fast, because the lookup (`k in l`) done on every insert is much faster than O(N) (O(1) on average or O(logN) if it is implemented with a balanced tree).

My conclusion is:

Arrays work just the way you expect them to work.

Anyway thanks for a nice write-up!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.