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.