Difference between revisions of "JavaScript Arrays"

From Techotopia
Jump to: navigation, search
(What is an Array)
(What is an Array)
Line 1: Line 1:
 
In [[Introducing JavaScript Variables]] and [[JavaScript Variable Types]] we looked at storing data (such as numbers, strings and boolean true or false values) in memory locations known as variables. The variable types covered in those chapters were useful for storing one value per variable. Often, however, it is necessary to group together multiple variables into a self contained object. This is where the concept of JavaScript Arrays comes in.
 
In [[Introducing JavaScript Variables]] and [[JavaScript Variable Types]] we looked at storing data (such as numbers, strings and boolean true or false values) in memory locations known as variables. The variable types covered in those chapters were useful for storing one value per variable. Often, however, it is necessary to group together multiple variables into a self contained object. This is where the concept of JavaScript Arrays comes in.
  
== What is an Array ==
+
== What is a JavaScript Array ==
  
 
A JavaScript array is an object that contains a number items. Those items can be variables (such as strings or numbers) or even other objects (such as Image objects or custom objects which you as a JavaScript developer have created). Once you have grouped all the items into the array you can then perfrom tasks like sorting the array items into alphabetical order, accessing and changing the value assigned to each array item and passing the group of items as an argument to a JavaScript function (see [[Understanding JavaScript Functions]]) by passing just the array object.
 
A JavaScript array is an object that contains a number items. Those items can be variables (such as strings or numbers) or even other objects (such as Image objects or custom objects which you as a JavaScript developer have created). Once you have grouped all the items into the array you can then perfrom tasks like sorting the array items into alphabetical order, accessing and changing the value assigned to each array item and passing the group of items as an argument to a JavaScript function (see [[Understanding JavaScript Functions]]) by passing just the array object.

Revision as of 14:07, 15 May 2007

In Introducing JavaScript Variables and JavaScript Variable Types we looked at storing data (such as numbers, strings and boolean true or false values) in memory locations known as variables. The variable types covered in those chapters were useful for storing one value per variable. Often, however, it is necessary to group together multiple variables into a self contained object. This is where the concept of JavaScript Arrays comes in.

What is a JavaScript Array

A JavaScript array is an object that contains a number items. Those items can be variables (such as strings or numbers) or even other objects (such as Image objects or custom objects which you as a JavaScript developer have created). Once you have grouped all the items into the array you can then perfrom tasks like sorting the array items into alphabetical order, accessing and changing the value assigned to each array item and passing the group of items as an argument to a JavaScript function (see Understanding JavaScript Functions) by passing just the array object.

In this chapter we will look in detail at how to create and manipulate JavaScript arrays.

How to Create a JavaScript Array