Skip to content

Dot operator in JavaScript | Example code

  • by

The JavaScript dot (.) operator is simply an operator that sits between its operands, just like + and -. The variables stored in an object that we access via the dot operator are generically called properties. 

JavaScript’s object support is the notion of chaining dots together to dive down into complex structures.

Dot operator in JavaScript

Simple example code access the object property using dot notation.

<!DOCTYPE html>


    function Student(name, age, standard) { = name;
      this.age = age;
      this.standard = standard;
    let student = new Student("Rohan", 18, 12);




Dot operator in JavaScript

Using dot operator with functions

Functions are objects, and they can have properties just like any other object.

var t = function() {
}; = function() {

t.favColor = 'red';
t.shoeSize = 12;

Output: bar

Do comment if you have any doubts or suggestions on this JS operator topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *