how to add property to string js code example
Example 1: add property to string js
const s = 'Hello world!'
s.user = 'Jack'; // no error if used without 'use-strict'
console.log(s.user); // undefined
Example 2: 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";