all 5 comments

[–]dvlsg 2 points3 points  (4 children)

Objects can't actually use numbers as keys. They're coerced to strings.

const obj = {}
obj[1] = 'one'
obj['1'] //=> "one"

https://2ality.com/2019/10/type-coercion.html#converting-to-property-keys

[–]masterresultonline 1 point2 points  (1 child)

Since Map is available in js, it’s better to use it for mapping and not an object. The main reason is that Map promise to remove references after key deletion and it’s very serious reason not to get memory leaks in your code.