Professional Web Design Bristol  - Beework Logo



Generate JavaScript Array Code

Generates the code to create a JavaScript array

Array Name  :
Number in Array  
Array Type  string  number
Copy and paste this code to the <HEAD> section of your page

Array

Object. Lets you create arrays and work with them.

    Syntax

    To create an Array object:

    1. arrayObjectName = new Array([arrayLength])
    2. arrayObjectName = new Array([el0, el1, ..., el3])
    To use Array objects:

    1. arrayObjectName.propertyName
    2. arrayObjectName.methodName(parameters)

      Parameters

      arrayObjectName is either the name of a new object or a property
      of an existing object. When using Array properties and methods, arrayObjectName is either the name of an existing Array object or
      a property of an existing object.

      arrayLength is the initial length of the array. You can access this value using the length property.

      elementn is a list of values for the array's elements. When this form is specified, the array is initalized with the specified values as its elements, and the array's length property is set to the number of arguments.

      propertyName is one of the properties listed below.

      methodName is one of the methods listed below.

        Property of

        None.

          Implemented in

          Navigator 3.0

            Description

            The Array object is a built-in JavaScript object.

            You can specify an initial length when you create the array. The following code creates an array of five elements:

            billingMethod = new Array(5)
            When you create an array, all of its elements are initially null.
            The following code creates an array of 25 elements, then assigns values to the first three elements:

            musicTypes = new Array(25)
            musicTypes[0] = "R&B"
            musicTypes[1] = "Blues"
            musicTypes[2] = "Jazz"
            An array's length increases if you assign a value to an element
            higher than the current length of the array. The following code
            creates an array of length zero, then assigns a value to element 99.
            This changes the length of the array to 100.

            colors = new Array()
            colors[99] = "midnightblue"
            You can construct a dense array of two or more elements starting
            with index 0 if you define initial values for all elements. A dense
            array is one in which each element has a value. The following code creates a dense array with three elements:

            myArray = new Array("Hello", myVar, 3.14159)
            In Navigator 2.0, you must index arrays by their ordinal number,
            for example document.forms[0]. In Navigator 3.0, you can index arrays by either their ordinal number or their name (if defined).
            For example, suppose you define the following array:

            myArray = new Array("Wind","Rain","Fire")
            You can then refer to the first element of the array as
            myArray[0] or myArray["Wind"].

              Properties

              The Array object has the following properties:

              Property Description
              length
              Reflects the number of elements in an array
              prototype
              Lets you add a properties to an Array object.