set
Add or modify object properties.
const obj = {a: "value1"};
obj.set("b", "value2"); // insert { b: "value2" };
obj.set("b", "editedValue2"); // b already exists, so this will edit the value to "editedValue2"
Syntax
set(key, value)
Returns
The same object.
Notes
- If the key doesn't exist, it will be added to the object.
- If the key does exist, then the existing value will be modified.