Q:

How to execute node js functions one after another which dynamically listed using their names in a string array

I need to achieve following in my Node.js program. 

How create a function array from their names provided in strings? 
How to execute those functions one after another. Not asynchronously. 
How to pass parameters for those functions. 

Suggest me a better approach to achieve this or code snippet somewhere already implemented this.

A:

You can do like this;

function foo(v){console.log("foo: ",v)};
function bar(v){console.log("bar: ",v)};

var funs = ["foo", "bar"],
       i = 0;
while (i < funs.length) this[funs[i]](i++);

Well of course your functions definitions might reside in a particular scope and you may need to invoke them from within whatnot..! In that case you can of course wrap the above code in a function and bind it to whatever scope your function definitions are made in. Such as

var obj = {
           foo: function(v){console.log("foo: ",v)},
           bar: function(v){console.log("bar: ",v)}
          },
   funs = ["foo", "bar"],
 runner = function(a){
            var i = 0;
            while (i < a.length) this[a[i]](i++);
          }.bind(obj);
     
runner(funs);

