Javascript build-in Array object reference.

Create arrays:

To create an array: new Array([param])
You uses the new keyword to create an array object.
To use as a function: Array([param])
When the Array object is used as a function the return will be an array as well.
param: The param argument is optional. If it is absent an empty array is returned.

If the param argument is present it can be one of the following:

  1. A number indicating the size of the array you want to create.
  2. A comma separated list of data values the array shall contain.
An example of using the new Array(param):
<script type="text/javascript">
var stringArr= new Array("Boolean","Math","Number","Object","String");
document.write("String array: "+stringArr+"<br>");
var arrObj= new Array(10);
document.write("Array with 10 undefined elements: "+arrObj+"<br>");

General information about the object member types:

  1. Prototype created methods, properties or constants can only be used on instances of an object or on a primitive datatype.
  2. Constructor created methods, properties or constants can NOT be used on instances of an object or on a primitive datatype.

Prototype Methods:

Syntax: concat([item1[ ,item2 [, ...]]])
When the concat method is called with zero or more arguments item1, item2, etc., it returns an array containing the array elements of the object followed by the array elements of each argument in order.
Return value: A new array.
An example of using the concat() :

Prototype Properties:

Syntax: Array.prototype.constructor
This property of the Array.prototype holds the reference back to the Array object.
Important note: This is the same as the constructor property of an instantiated object

Constructor (Array) Properties:

Syntax: Array.constructor
The constructor property is a reference to the function that will be invoked to create a Array object.

© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.