When you want to work with multiple related values, you can use the Array object. The new keyword is required when creating an array of object type data, like an array of string objects. The new keyword is not required when creating an array of simple variable types, like integers. In this article you learn about mutidimensional arrays, and study examples of how to use each Array Object method.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact Advertise on Bucaro TecHelp Advertise Here RSS News Feeds News Feeds

HTML5 Solutions: Essential Techniques for HTML5 Developers

Essential Techniques for HTML5 Developers

HTML5 brings the biggest changes to HTML in years. Web designers now have new techniques, from displaying video and audio natively in HTML, to creating realtime graphics on a web page without a plugin.

This book provides a collection of solutions to all of the most common HTML5 problems. Every solution contains sample code that is production-ready and can be applied to any project.

Click Here

Using the Java Script Array Object

An array is a structure for storing multiple data values. Each value in an array is given an index number. To access a particular data item in an array, use the name of the array and the index number of the particular data item.

Creating an Array

To create an Array, use new keyword. The code shown below creates an array named color that can hold three data items.

var color = new Array(3);

Putting Data into an Array

To enter data into an array, create a series of assignment statements, one for each data item in the array. The code shown below populates the color array with the names of three colors.

color[0] = "red";
color[1] = "green";
color[3] = "blue";

Note that array indexes are zero-based, in other words the index values start with 0 for the first element.

The new keyword is required only when creating an array with object type data. In the previous example we created an array of string objects. The new keyword is not required when creating an array of simple variable types. The code shown below creates and populates an array with integers.

var digit = [1, 2 ,3];

The code shown below creates and populates an array with characters.

var char = ['a', 'b' ,'c'];

Accessing Array Values

To access a particular data item in an array, use the item's index number. The code shown below displays the value of the second data item in the array of characters created above.

alert(char[1]);

Output:

b

To access the entire contents of an array, use the name of the array without an index number. The code shown below displays the value of all the data items in the array of characters.

alert(char);

Output:

a,b,c

RSS Feed RSS Feed



Web Design Sections

Eloquent JavaScript: A Modern Introduction to Programming

Eloquent JavaScript

Eloquent JavaScript Eloquent JavaScript goes beyond the cut-and-paste scripts of the recipe books and teaches you to write code that's elegant and effective. You'll start with the basics of programming, and learn to use variables, control structures, functions, and data structures. Then you'll dive into the real JavaScript artistry: higher-order functions, closures, and object-oriented programming.

Reader Anthony says, "This book is not your typical Javascript book. Others have a utilitarian approach. In stark contrast, Eloquent JavaScript does not merely provide you a checklist of things to learn but rather paints a panorama of the possibilities that programming provides. Javascript is merely the tool used to introduce these to the reader.

Click here for more information.


[Site User Agreement] [Advertise on This site] [Search This Site] [Contact Form]
Copyright©2001-2011 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268