How to execute a method passed as parameter to function

前端 未结 8 644
旧巷少年郎
旧巷少年郎 2020-12-13 03:44

I want to write my own function in JavaScript which takes a callback method as a parameter and executes it after the completion, I don\'t know how to invoke a method in my m

8条回答
  •  情深已故
    2020-12-13 04:05

    function myfunction(param1, callbackfunction)
    {
        //do processing here
       callbackfunction(); // or if you want scoped call, callbackfunction.call(scope)
    }
    

提交回复
热议问题