using objects in javascript code example
Example 1: how to create object in javascript with class
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
}
Example 2: objects in javascript
let object = {
'key1': 'value1',
'key2': 'value2',
'keyn': 'valuen',
};
console.log(object);
Example 3: javascript object string property
// Also useful for dynamic strings, e.g. `thing-${variable}`
myObject['thing'] = true;