Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
56
rated 0 times [  63] [ 7]  / answers: 1 / hits: 110582  / 13 Years ago, mon, february 27, 2012, 12:00:00

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? Thanks.


More From » function

 Answers
10

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);

[#87193] Saturday, February 25, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
margob

Total Points: 302
Total Questions: 89
Total Answers: 100

Location: Guadeloupe
Member since Sat, Jul 25, 2020
4 Years ago
margob questions
Mon, Jun 29, 20, 00:00, 4 Years ago
Wed, Sep 26, 18, 00:00, 6 Years ago
;