JavaScript Tutorials - Herong's Tutorial Examples - 2.33, by Herong Yang
What Is an Array
This section provides a quick description of what is an array in JavaScript and a tutorial example showing JavaScript array features.
Like many programming languages, JavaScript support arrays allowing you to store and retrieve a list of elements.
But unlike many other languages, JavaScript does not have an explicit array data type. Instead, it provides you an Array object type to let you create arrays as objects. Here are the main features of an array in JavaScript:
Here is a tutorial example JavaScript that shows you some of the features mentioned above:
<html> <!-- Array_Features.html Copyright (c) 2002 HerongYang.com. All Rights Reserved. --> <head><title>Array Features</title></head> <body> <pre> <script type="text/javascript"> // Creating a new array of mixed data types var account = ["Saving", 999.99, true]; // Store new value to the array account[2] = false; // Retrieving an element document.write("Account type: "+account[0]+"\n"); // Calling an array method account.push(5.25/100); document.write("Interest rate: "+account[3]*100+"%\n"); </script> </pre> </body> </html>
The output of this sample JavaScript is:
Account type: Saving Interest rate: 5.25%
Table of Contents
ECMAScript Language Specification and JavaScript Dialects
Data Types, Variables and Expressions
►Creating, Accessing, and Manipulating Arrays
Accessing Array Elements with Indexes
Truncating and Iterating Array Elements
Array Object Instance Method Examples
Defining and Calling Functions
Web Browser Supporting JavaScript
Server-Side and Client-Side Web Scripting
Defining Your Own Object Types
Inheritance of Properties and Methods through the Prototype Object Chain
'jrunscript' - JavaScript Shell Command from JDK
Using Functions as "Function" Objects
Introduction to Built-in Object Types
W3C's Document Object Model (DOM) Specifications