Using objects in JavaScript
Objects are non-primitive values; they are a collection of properties. A property is a key-value pair. The key is always a string, and the value can be any type of value, including other objects.
Basic operations
Objects are the most versatile structure in JavaScript. In this section, we will learn how to create objects, how to access and modify their properties, and how to iterate over the properties of an object.
Creating an object
You can create an object using the object literal syntax, that is, using curly braces:
const person = {}
You can also create an object and directly add properties:
const person = { name: 'Jane', }
You can store any type of value in an object, including other objects or functions (methods):
const person = { name: 'Jane', id: 1, favoriteColors: ['blue', 'green'], ...