How do I pass multiple arguments into a javascript callback function?

前端 未结 2 591
轻奢々
轻奢々 2021-02-04 03:38

Javascript code:

function doSomething(v1,v2){ //blah; }

function SomeClass(callbackFunction,callbackFuncParameters(*Array*))={
   this.callback = callbackFuncti         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 04:32

    You probably want to use the apply method

    this.callback.apply(this, parameters);
    

    The first parameter to apply indicates the value of "this" within the callback and can be set to any value.

提交回复
热议问题