
Understanding Objets in JavaScript
Objects in JavaScript are very interesting because internally everything that is not a primitive data type is an object. What is an Object? An object is a non-primitive data type that can store multiple values. It is used to store related data and functionality together in a single, manageable unit. Objects store data as comma-separated key-value pairs. You can think of an object as a container that holds multiple variables together. Let's look at a code snippet of an object storing multiple values. const user = { name : " someone " , age : 12 , course : " Web Development " console . log ( user . age ) //Output : 12 } In this example name , age , course are keys and someone , 12 , Web Development are values Empty Object : An object can also be empty. // empty object -> {} This creates an empty object with no properties you can add them later. Diagram As you can see in the example above, an object in JavaScript is created using curly braces {}. You can store the object in a variable. No
Continue reading on Dev.to Webdev
Opens in a new tab


