Global GuideLine Home HTML Tutorial JavaScript Tutorial SQL Tutorial CSS Tutorial SEO Tutorial XML Tutorial XSLT Tutorial Articles Tutorial Interview Questions and Answers Guide Jobs GuideLine Bookmark With Google Bookmark With Yahoo Bookmark With FaceBook Bookmark With Live Follow @GlobalGuideLine on Twitter Bookmark Global GuideLine
JavaScript using Arrays, JavaScript Tutorial, Global Guide Line Technology.
Bookmark this webpage. Bookmark: JavaScript using Arrays, JavaScript Tutorial Global Guideline is UNITED STATES's favorite website

      Home                    

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.                

Learn JavaScript with Examples
Learn JavaScript with hundred of short examples with code and output.
Complete_JScript_Examples.php

JScript Interview Questions & Answers
Learn JavaScript by thousands of Interview Questions & Answers.
JavaScriptQuestions/index.php

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">

  employee1="John";
  employee2="Smith";
  employee3="Haney";
  employee4="Lara";
  employee5="David";

</script>

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);
  employees[0]="John";
  employees[1]="Smith";
  employees[2]="Haney";
  employees[3]="Lara";
  employees[4]="David";
 
  //now displaying the array elements content using JavaScript for loop
  for (i = 0; i < employees.length; i++)
  {
    document.write(employees[i].bold() + "<br/>");
  }

</script>

Output of JavaScript Array Example



     Back             Next     
 

JavaScript Array Object Examples



JavaScript Variables Examples



In order to link this page as Reference, click on below text area and pres (CTRL-C) to copy the code in clipboard or pres right click then copy the following lines after that past into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code:

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

Copyright © 2005-2006 www.globalguideline.com All rights reserved. Join Global Guide Line community. 300 visitors are online now