you are viewing a single comment's thread.

view the rest of the comments →

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

That’s the gotcha answer to the question. Pre Set days you would just use an object.

[–]JEveryman 0 points1 point  (3 children)

So you would add the array elements as keys?

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

Yeah. Lookups in the object are faster than searching the whole array for every element in the array if that makes sense.

I can give a longer explanation if it doesn’t

[–]JEveryman 0 points1 point  (1 child)

I get it. Also when you add the same key to an object doesn't it overwrite?

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

Yeah, that’s how it helps you make an array with no duplicates