Call function from an array one by one - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

Call function from an array one by one

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from   w  ww  . ja v  a 2 s .  c  o m
var funcs = [
    function () {
        console.log('1');
    },
    function () {
        console.log('2');
    },
    function () {
        console.log('3');
    }
];
var currentFunc = funcs.shift();
while (currentFunc) {
    currentFunc();
    currentFunc = funcs.shift();
}
    });

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

Related Tutorials