javascript - JS Make function object return -


i creating function object. when run object returns undefined.
instance, in jsfiddle example, when try alert(test(8)), function runs , returns 13 when create function object, 'alert(func(8))' returns undefined.

<button onclick="start()">start test</button>  <script>      function test(num) {         alert("running...");         return num + 5;     }      function start(){         alert(test(8));          var func = new function("num", "test(num)");         alert(func(8));      }  </script> 

because in second func, not returning value of test(num)

function test(num) {    alert("running...");    return parseint(num) + 5;  }    function start(){    alert(test(8));      // return value obtained on calling test(num)     <------------    var func = new function("num", "return test(num)");    alert(func(8));  }    start();


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -