add properties to a javascript object code example
Example 1: add property to object javascript
let yourObject = {};
//Examples:
//Example 1
let yourKeyVariable = "yourKey";
yourObject[yourKeyVariable] = "yourValue";
//Example 2
yourObject["yourKey"] = "yourValue";
//Example 3
yourObject.yourKey = "yourValue";
Example 2: javascript object string property
// Also useful for dynamic strings, e.g. `thing-${variable}`
myObject['thing'] = true;