I am really really new to nodejs. Is there any way to convert function content to string? Something like, if I have:
function() {
....
}
I'd like to have "function() { .... }".
Is such thing possible?
Functions already have a toString() method... so just (function() {}).toString() should work.
For example, in the node REPL:
> (function() { console.log("hello"); }).toString()
'function () { console.log("hello"); }'
Here's a link to some documentation.
Function.prototype.toString() is standard. The indentation parameter referenced in the MDN docs is non-standard, but this solution doesn't rely on that.
(function() {...}).toString()?