Director Help

Checking items in arrays

You can determine the characteristics of an array and the number of items the array contains by using the following methods:

  • To display the contents of a list, use the put() or trace() function, passing the variable that contains the list as a parameter.
  • To determine the number of items in an array, use the Array object’s length property.
  • To determine an array’s type, use the constructor property.

    The following example illustrates determining the number of items in an array by using the length property, and then returning the type of object by using the constructor property:

    // JavaScript syntax
    var x = ["1", "2", "3"];
    trace(x.length) // displays 3
    trace(x.constructor == Array) // displays true