masSdev masSdev - 1 year ago 124
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



Answer Source

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}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download