JavaScript using Arrays, JavaScript Tutorial, Global Guide Line Technology.
Forum | Blog |


Basic JavaScript Guide.
 JScript Introduction.            
 JScript Why?                       
 JScript Recognitions.          
 JScript onMouseover.         
 JScript with Buttons.           
 JScript Alerts.                     
 JScript Variables.               
 JScript Operators.               
 JScript Functions.               
 JScript Prompts.                 
 JScript Conditions.             
 JScript Validations.            
 JScript Confirmation Boxes.
 JScript Browser Detection.  
 JScript Redirection.            
 JScript on Links.                 
 JScript Switch.                    
 JScript Loops.                     
 JScript Events.                    
 JScript Exception Handling.
 JScript Reserve Characters. 
 JScript with Objects.            
 JScript Math Object.           
 JScript using Dates.             
 JScript using String.            
 JScript using Arrays. 
 JScript Operations.              
 JScript Handling Cookies.   
 JScript in Mapping.             
 JScript Time Out.                
 JScript Summary.                

JavaScript Tutorial >> JavaScript using Arrays.

     Back             Next     

What is JavaScript Array?

Now JavaScript Tutorial will guide us that JavaScript arrays are one way of keeping a program more organized and normalize. JavaScript Arrays allow us to do some things that are difficult without them. Arrays are usually a group of the same type variable that use an index number to distinguish them from each other. And suppose we want to write out 5 names of employees at Global Guide Line, and we use JavaScript variables for each one of our employee. Then we need to define 5 JavaScript variables  like the below code...

Instead of JavaScript Array using JavaScript Variables

<script type="text/javascript">



Suppose we have more then 1000 employees in an organization then either we define 1000 JavaScript variables in our JavaScript.  No However, a better way may be to use an JavaScript array. To define an array, we need to follow the following steps.

Syntax of Array in JavaScript

var Name_of_Array= new Array(number_of_elements);

Name_of_Array would be the name we want to give the JavaScript array variable, the number_of_elements argument is the number of indexes we want in JavaScript array to define. So, for our employee names, we could write

Example of JavaScript Array

<script type="text/javascript">
  var employees= new Array(10);
  //now displaying the array elements content using JavaScript for loop
  for (i = 0; i < employees.length; i++)
    document.write(employees[i].bold() + "<br/>");


Output of JavaScript Array Example

     Back             Next     

JavaScript Array Object Examples

JavaScript Variables Examples

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2023 All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 447 visitors are online now