Dot-Syntax

By: Dusty Arlia
Published on Semptember 24, 2012
Last Updated on Wednesday, July 08, 2015 at 7:05 PM
Total Updates: 8

Dot-syntax is the name of an object followed by a dot (.) and then one of the object's properties or methods (technically methods are properties). The dot connects the object with its property or method. Here's a look at dot-syntax:

[object].[property]

When we say that the dot "connects" the object to its property, we are saying that the object queries that property name. By accessing its property you can use its value and by connecting to the object's method, you can execute it. If that property doesn't exist yet, then this expression should be creating this property. Here is an example of the document object connecting to its write() method:

document.write('Hello World');

In this example above, the document object uses its write() method to print the string "Hello World" to the screen.

Here is a different example of an array object named shoppingCartArrayName connecting to its length property:

var i = shoppingCartArrayName.length;

In this example above, the variable i is declared and then assigned the value of the length property of the shoppingCartArrayName array object. This value should be equal to the number of elements in the shoppingCartArrayName array.

Comments:

Ad: