What is Dot Notation in JavaScript?

Learn about what JavaScript Dot Notation is.

Don’t pay much attention to the “notation” part of dot notation, it can make it sound more complex than it is. Dot notation is simply the act of reading or assigning values to an object by using a dot (.).

Let’s say you have an object called dog:

const dog = {
    name: 'Naya',
    age: 2

Now we want to read one of its values, e.g. the age of the dog:

// Result: 2

That’s reading values from an object with dot notation.

Now let’s give a new value to the dog, e.g. let’s say Naya has a birthday:

// Assign new age value to dog
dog.age = 3

// Now writing console.log(dog.age) returns 3.

That’s assigning values to an object with dot notation.

Has this been helpful to you?

You can support my work by sharing this article with others, or perhaps buy me a cup of coffee 😊


Share & Discuss on