Creating Javascript objects one
How to solve it
There are multiple ways to create JavaScript objects. But, in 99.9% of the cases, there is only one approach that I use: the Object initializer. Using this approach, creating objects is very straightforward. All you have to do is to encapsulate a list of key-value pairs with curly braces. The following example code creates an object with one property that has a key 'x' and a value 1:
const object = { x: 1 };
Object properties can store any JavaScript type - although property values that are functions are officially called Object methods. You can even store another object as property value which can have its own properties. The following example creates an object with multiple properties that have values of various types:
const object = { a: 1, b: 'text', c: { a: 1 }, d: false, e: function(){} };