Member-only story
A Beginner’s Guide to Object Literals in JavaScript
Understand objects in JavaScript with examples.

What are Objects?
Objects are a data structure in JavaScript like arrays but the difference is that objects are useful when we want to store data that is unordered or where preserving the order of our data does not matter. As an example, if you wanted to store details about a dog, whilst we could achieve this using an array, an object would be more appropriate. This is because we are more interested in the details about the dog as opposed to preserving any order of the details.
Objects also enable us to extend the object to include data about another object. So our dog object could store data about multiple dogs. An object is a container for sets of key-value pairs. Going back to the dog example, if I wanted to store details about a dog called Ted then in the object I may want to store the dog's name, age, and breed. So the name would be the key and the value would be the string ted.
const ted = {
name: "Ted"
};//name is the key
//"Ted" is the value
Creating Objects
As with arrays objects are reference types so the same rules apply when it comes to using let or const. We can change the object if it was…