Return an array from a function : Function Return « 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.7.Function Return
7.7.1.return
7.7.2.Returning Values
7.7.3.Return value from a function
7.7.4.Return boolean value from function
7.7.5.Return an array from a function