Arrays as Objects : Introduction : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » Introduction »

 

Arrays as Objects








It is possible to access the elements of arrays as properties if a string index is used.

The [] operators and dot notation can be used interchangeably when accessing the contents of the array.












<HTML>
<SCRIPT LANGUAGE="JavaScript">
<!--
    function populateArray(table) {
      table.A=46;
      table.B=23;
      table["B"]=14;
      table["C"]=15;
    }
    function displayArray(table) {
      document.write(table['A']," A.<BR>");
      document.write(table['B']," B.<BR>");
      document.write(table.B," B.<BR>");
      document.write(table.C," pairs of C.");
    }
    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
» Introduction