How to run function on JavaScript? -
i want run function sent parameter on javascript, example create script, want script print "successful test" script print whale function text. thus, how can run function sent parameter function? test=function (p1) { return p1; } var result=test(function(){ return "successful test"; }); console.log(result); you should return return p1(); var test=function (p1) { return p1(); } var result=test(function(){ return "successful test"; }); console.log(result); jsfiddle demo