March 19, 2002 - Using Associative Arrays | WebReference

March 19, 2002 - Using Associative Arrays

Yehuda Shiran March 19, 2002
Using Associative Arrays
Tips: March 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Like most modern programming languages, JavaScript supports associative arrays. The index in associative arrays is a string (including blanks). For example, the following code initializes a two-element associative array:

  var a = new Array();
  a["The day after Sunday"] = "Monday";
  a["The day after Monday"] = "Tuesday"; 
Let's test the value of the first and second elements.