Get argument of executed function in function Javascript -


i have function measures time execution of function, , cleans dom after each execution:

function measuretimeexecution(domid, testfunc){     console.time("timer");     for(var = 0; < 10; i++){        testfunc();        var getdiv = document.getelementbyid(domid);     }     getdiv.empty();     console.timeend("timer"); } 

function creates new ul

 function createlist_task_2(divid){         var createnewul = document.createelement("ul");         createnewul.id = "phonelist";         document.getelementbyid(divid).appendchild(createnewul);         for(var = 0; < phones.length;i++){              var chunk = "<li>" + phones[i].age +"<br>" + phones[i].id +"<br><img src='"                 + phones[i].imageurl  +"'/><br>"  + phones[i].name + "<br>" + phones[i].snippet + "</li>";              document.getelementbyid("phonelist").innerhtml += chunk;         }     } 

but iy gives me: uncaught typeerror: testfunc not function;

example:

measuretimeexecution("div1", createlist_task_3("div1")); 

is possible somehow domid in measuretimeexecution argument of testfunc?

the problem when calling measuretimeexecution runing parameter, instead pass function again.

look @ code should work

measuretimeexecution("div1", function () { createlist_task_3("div1"); }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -