Dela via


JScript Arrays

An array groups related pieces of data in one variable. A unique number, called an index or subscript, combined with the shared variable name distinguishes each element in the array. Arrays result in shorter and simpler code in many situations because loops can deal efficiently with any number of elements by using the index number.

JScript provides two different types of arrays, JScript array objects and typed arrays. In JScript array objects, which are sparse, a script can dynamically add and remove elements, and elements can be of any data type. In typed arrays, which are dense, the size is fixed, and elements must be the same type as the base type of the array.

In This Section

  • Arrays Overview
    Describes the two types of JScript arrays, the differences between the types, and how to choose the appropriate array type.

  • Array Declaration
    Explains the concept of declaring arrays and how declaring arrays with the new operator differs from declaring array literals.

  • Array Use
    Demonstrates how to access the elements of one-dimensional arrays, multidimensional arrays, and arrays of arrays.

  • Arrays of Arrays
    Explains the concept of arrays of arrays, why arrays of arrays are useful, and how to use them.

  • Multidimensional Arrays
    Explains the concept of multidimensional arrays, how they differ from arrays of arrays, and how to use them.

  • Array Data
    Illustrates how to compose array literal values and how to combine data types in the same array.

  • Array Object
    Reference information that describes the JScript Array object, how to use it, and how it interoperates with the System.Array data type.