Catching an array from return - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

Catching an array from return

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
function foo1() {/*ww w  . j  av a  2  s .co m*/
  var a = [1,2,3,4,5];
  return a;
}
function foo2() {
  var b = [6,7,8,9,10];
  return b;
}
function init() {
  var a1 = foo1();
  var b1 = foo2();
  var d = [];
  for (var i=0; i<a1.length; i++) {
    d.push(a1[i], b1[i]);
  }
  console.log(d);
}
init();

      </script>  
   </body>
</html>

Related Tutorials