Array String Indexes : String Indexer : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » String Indexer »

 

Array String Indexes








It is possible to index arrays using strings.

To access an element, a string index value is placed into the [] operator.












<HTML>
<SCRIPT LANGUAGE="JavaScript">
<!--

    function populateArray(myArray) {
      myArray["A"]=4;
      myArray["B"]=2;
      myArray["C"]=1;
      myArray["D"]=5;
    }
    function displayArray(myArray){
      document.write(myArray['A']," A.<BR>");
      document.write(myArray['B']," B.<BR>");
      document.write(myArray['C']," C.<BR>");
      document.write(myArray['D']," pairs of D.");
    }
    var myArray = new Array();
    populateArray(myArray);
    displayArray(myArray);

-->
</SCRIPT>
</HTML>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Array
» String Indexer