DEV Community


Discussion on: Daily Coding Problem #1

minche profile image
Minja Davidović

there was actually an article recently that touched on the subject mentioned by Serhii Sakal
I was wondering, why not just use an object instead of an array?
let's take a simple example, where you have something like this

const a = [1, 2];
a[1000] = 1000;


and look at the size of a.
even with your example, the created lookup array is bigger than the given array, so you're using more memory than needed.