masSdev masSdev - 4 months ago 30
Javascript Question

Add duplicate key in javascript map object

Is it possible to add duplicate key in javascript map object?

I need to add map object with only null values as key which will be later replaced.I can't use array since I will replace this key later and it should be of this order




You can't have duplicate keys in a map object, that's actually how you differentiate them. You can only change values so with your example you could do something similar to

{"1": null, "2": null}