Add the below code in your js.
// Defines push method to push the key value pair Object.prototype.push = function( key, value ) this[ key ] = value; return this;
// Declare variable for map; var obj2 = ; obj2 = "key1": "value1", "key2": "value2"; // a way of adding map data. obj2.push( "key3", "value3" ); console.log ( obj2 ["key2"] ); // Prints: value2 console.log ( obj2 ); // Prints: key1: "value1", key2: "value2", key3: "value3"
Thats all you can construct the data structure as you wish.

Leave a comment