Answers for "map duplicate keys JS"

0

map duplicate keys JS

// One can create a unique map. When there are two same keys, they can be stored as:

const map = {
    "Truck": [{ "Red": true }],
    "Compact Sedan": [{ "Black": false }, { "Blue": false }]
}

map["Compact Sedan"][0]; // { "Black": false }
map["Compact Sedan"][1]; // { "Blue": false }
Posted by: Guest on July-15-2021
0

how to create duplicate key array in javascript

var obj = {
  key1: []
};

obj.key1.push("something"); // useing the key directly
obj['key1'].push("something else"); // using the key reference

console.log(obj);

// ======= OR ===========
Posted by: Guest on July-02-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language