Pass an array to a function : Function Parameters « Function « JavaScript Tutorial






<HTML>
   <HEAD>
   <TITLE>
   Iteration Two
   </TITLE>
   <SCRIPT>
   function makeArray() {
        var myArray = new Array(4);
        myArray[0] = "A";
        myArray[1] = "B";
        myArray[2] = "C";
        myArray[3] = "D";
        return myArray;
   }
   function showArray(theArray){
        var quote = "";
        for (var i = 0; i < theArray.length; i++){
            quote += theArray[i] + " ";
        }
        return quote;    
   }
   </SCRIPT>
   </HEAD>
   <BODY>
   <H1>
   <SCRIPT>
      var x = makeArray();
      document.write(showArray(x));
   </SCRIPT>
   </H1>
   </BODY>
</HTML>








7.3.Function Parameters
7.3.1.Pass value to a function
7.3.2.Pass number to a function
7.3.3.Pass integer to function
7.3.4.Pass Form value to a function
7.3.5.Use functionName.arguments to reference the arguments
7.3.6.Pass an array to a function