how to add a value to a key in an object javascript code example
Example: js add key to object
// given
const obj = {
key1: value1,
key2: value2
};
// add pair
obj["key3"] = value3;
obj.key4 = value4;
// given
const obj = {
key1: value1,
key2: value2
};
// add pair
obj["key3"] = value3;
obj.key4 = value4;