Passing a function as an argument in a javascript function

后端 未结 7 1129
眼角桃花
眼角桃花 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:28

    In fact, seems like a bit complicated, is not.

    get method as a parameter:

     function JS_method(_callBack) { 
    
               _callBack("called");  
    
            }
    

    You can give as a parameter method:

        JS_method(function (d) {
               //Finally this will work.
               alert(d)
        });
    
    0 讨论(0)
提交回复
热议问题