We have three different ways to access properties in Javascript Objects, all are very useful and can be combined with each other. The methods are:

  • Use the assessor **.** with the property: **object.property**
  • Use the property name within brackets, **object['property']**
  • Using Object destructuring **const { property } = object**

Let’s see how each syntax works to access properties in objects. And understand when it is reasonable, depending on the situation, to use one way or another.

Table of Contents

Creating Objects in Javascript

Before we understand how to access the properties in objects, let’s see how we can create these objects.

Objects in Javascript are sets of key-values that, unlike arrays, have no defined order.

//{key : value}
{userName: "@EverythingDebug" }

The simplest and most efficient way to create a Javascript Object is using the literal object form with **{}**. You simply need to create a variable, in the example below I called the variable **myProfile**, and pass the key-value properties to this variable, very simple.

const myProfile = {
        title: "@EverythingDebug",
        url: "https://twitter.com/EverythingDebug",
        tweets: 9,
        followers: 4,
        following: 6
      };

#javascript

3 Powerful Ways to Access Properties in Javascript Objects
1.15 GEEK