Objects

Overview of objects in JavaScript.

Introduction

Almost everything in JavaScript is made up of objects. These are all the non-primitive types.

They include arrays, dates, and almost everything non-primitive. They are mutable values in JavaScript. To access their property or data, use . or [] operators.

How do we create these objects?

Creating objects

Objects are created using the {} operator. If we assign a variable to {}, we have an object with no properties.

Press + to interact
var obj = {}; // Declare our object
//print value and type of obj
console.log('Our object:',obj);
console.log('Type of our object:',typeof(obj));

On line 1, we created our first object and assigned it to the variable obj. On the lines that follow, see how it is printed and its type, nothing fancy so far.

Adding and modifying properties

While declaring or after declaring an object, we can assign and modify the properties of an object. A property is a ...