Javascript Tutorial Example
Example
Javascript Array
JavaScript Boolean
JavaScript Date
JavaScript Math
JavaScript Number
JavaScript String
Javascript Tutorial
Javascript Introduction
Javascript Syntax
Javascript Enable
Javascript Location
Javascript External
Javascript Operators
Javascript Variables
Javascript Functions
Javascript Events
Javascript Statements
Javascript If
Javascript Else If
Javascript While
Javascript For Loop
Javascript Comments
Javascript Array
Javascript Alert
Javascript Confirm
Javascript Prompt
Javascript Print
Javascript Redirect
Javascript Pop Up
Javascript Date
Javascript Form
Javascript Void 0
JavaScript Comparison
JavaScript Switch
JavaScript Try Catch
JavaScript Special Text
JavaScript Throw
JavaScript Math
JavaScript RegExp
Javascript String
Javascript Strings
Javascript Length
Javascript Split
Javascript Search
Javascript Replace
Javascript IndexOf
Javascript Compare
Javascript Advanced
Javascript getElementById
Javascript innerHTML
JavaScript Browser
JavaScript Cookies
JavaScript Animation
JavaScript Image Maps
JavaScript Timing
JavaScript Create Objects
JavaScript Summary
An array is a variable that can store many variables within it. Many programmers have seen arrays in other languages, and they aren't that different in JavaScript.
The following points should always be remembered when using arrays in JavaScript:
Creating an array is slightly different from creating a normal variable. Because JavaScript has variables and properties associated with arrays, you have to use a special function to create a new array. This example shows how you would create a simple array, store values to it, and access these values.
<script type="text/javascript">
<!--
var myArray = new Array();
myArray[0] = "php";
myArray[1] = "css";
myArray[2] = "html";
document.write(myArray[0] + myArray[1] + myArray[2]);
//-->
</script>
Notice that you set values and get values from an array by specifying the position, in brackets, of the value you want to use.
Imagine that you wanted to sort an array alphabetically before you wrote the array to the browser. Well, this code has already been written and can be accessed by using the Array's sort method.
<script type="text/javascript">
<!--
var myArray2= new Array();
myArray2[0] = "html";
myArray2[1] = "css";
myArray2[2] = "html";
myArray2.sort();
document.write(myArray2[0] + myArray2[1] + myArray2[2]);
//-->
</script>
Arrays are a very complex area of programming, especially in JavaScript. This lesson cannot possibly cover all the areas of JavaScript arrays, but we have compiled some useful resources for you to check out!

