Technical Training
JavaScript TutorialAccessing JavaScript array elements
JavaScript Arrays
Accessing the elements in an array:
An element in an array can be accessed by referring to the name of the array, followed by open braces [inside which the index number of the element to be accessed is placed and then the braces are closed using].
The index of an array in JavaScript starts with 0.
For example,
if a programmer wants to write the element “Institute” define in the array exforsys below.
It is written as follows:
document.write(exforsys[2])
var Exforsys=new Array( )
Exforsys[0]=”Training”
Exforsys[1]=”Division”
Exforsys[2]=”Institute”
Exforsys[3]=”Company”
will write Institute as output.
Editing the values or elements in an array:
It is also possible that the value or elements of the array defined can be edited or modified.
This is written using the same approach for accessing array elements.
For example,
if a programmer wants to change the value of “Division” to “Output” it can simply be written as follows:
Exforsys[1]=”Output”
Literal Array:
General format for defining the literal array is as follows:
var variablename=[“element1”,”element2”,…….]
For example, if a programmer wants to define an array named exforsys with the first element “Example”, the second and third elements of the array as undefined and the fourth element as “Training”, it can be written as follows:
var Exforsys=[“Example”, , , “Training”]
Thus, using this method, the programmer has the flexibility to leave elements undefined between the arrays.
JavaScript Tutorial
- JavaScript Browser Objects Part 2
- JavaScript Frame object
- JavaScript Form Object
- JavaScript FileUpload Object
- JavaScript Event Object Properties and Methods
- JavaScript Event Object
- JavaScript Elements and Embed Objects
- JavaScript Applet Objects
- JavaScript Browser Objects
- JavaScript Object Oriented Features
- JavaScript Window Object Open Method Part 2
- JavaScript Window Object Open Method
- JavaScript Window Object Timeout Methods
- JavaScript Location Object
- JavaScript Location Object Properties
- JavaScript History Object Properties and Methods
- JavaScript Document Object Methods Part II
- JavaScript Document Object Methods Part I
- JavaScript Document Object Properties
- JavaScript Document Object
- JavaScript Windows Object Properties Part II
- JavaScript Windows Object Properties Part I
- JavaScript DOM Window Object
- Working with JavaScript DOM Objects
- JavaScript Array Object Methods – Part II
- JavaScript Array Object
- JavaScript Array Object Methods – Part I
- JavaScript Boolean Object
- JavaScript OnError Event
- JavaScript Exception Handling – Part II
- JavaScript Exception Handling – Part I
- JavaScript Event Handler
- JavaScript Events Handling
- JavaScript Array Operations
- JavaScript Two Dimensional Arrays
- Passing values to JavaScript Function
- JavaScript Functions
- JavaScript Arrays
- JavaScript Iterative Structures - Part II
- JavaScript Iterative Structures - Part I
- JavaScript Math Object
- JavaScript Date Object
- JavaScript String Object
- JavaScript Objects
- JavaScript Confirm Box
- JavaScript Alert Box
- JavaScript Conditional Statements Part 2
- JavaScript Conditional Statements Part 1
- How to use JavaScript in HTML page
- JavaScript Variables
- JavaScript Features
- JavaScript Introduction







