Passing a function as an argument in a javascript function

后端 未结 7 1136
眼角桃花
眼角桃花 2020-12-08 00:25

I was wondering whether this is legal to do. Could I have something like:

function funct(a, foo(x)) {
  ...
}

where a is an ar

7条回答
  •  伪装坚强ぢ
    2020-12-08 01:25

    I would rather suggest to create variable like below:

    var deleteAction = function () { removeABC(); };
    

    and pass it as an argument like below:

    removeETC(deleteAction);
    

    in removeETC method execute this like below:

    function removeETC(delAction){ delAction(); }
    

提交回复
热议问题