In JavaScript (or Node.js), you can simply use the Object.prototype.toString()
method to console.log()
(or output) the function itself. For example:
function foo() { return 'bar'; } console.log(foo.toString());
Please note that for built-in methods, you would see [native code]
(or something similar) as the output. This is because these methods are not written in JavaScript.
Hope you found this post useful. It was published . Please show your love and support by sharing this post.