console.log javascript [Function]

后端 未结 1 932
逝去的感伤
逝去的感伤 2020-12-12 21:22

I\'m trying to log a function in javascript:

console.log(callback)
>>[Function]

I want to see what the function is. Can I do that? Th

相关标签:
1条回答
  • 2020-12-12 21:58

    If it's a user defined function you can use:

    console.log(callback.toString());
    

    Otherwise you'll just get something like [native code] since built in functions are not written in JavaScript.

    Example:

    function x(){}
    
    // Prints "function x(){}"
    (function(callback){ console.log(callback.toString()); })(x);
    
    0 讨论(0)
提交回复
热议问题