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
Post a Comment