JavaScript uses dot (.) notation for arrays and object access. You can access elements of an array using square bracket notation ([ ]) and elements of an object using dot (.) notation. JavaScript treats dot and square bracket notation as operators.
Dot notation uses the following format:
object.identifier
The identifier operand can be the literal name of the property, method, or variable name (in a dataset), without single or double quotation marks. The operand cannot be a string or variable that contains a string.
Square bracket notation uses the following formats:
array[expression] //
The array operand refers to an array, and the [expression] operand evaluates to an integer value for an array index.
object[expression] //
The object operand refers to an object, and the [expression] operand evaluates to a string that names a property of the object.
Note: Unlike dot notation, where the second operand is an identifier, the [expression] operand is a string.
Square bracket notation allows access to array elements and object properties. Square bracket notation also allows access to object properties without restricting the identifier operand as dot notation does.
|
Copyright © 2014 CA.
All rights reserved.
|
|