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?
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?
(function() {...}).toString()
?
– Benoir
Commented
Apr 3, 2013 at 17:10
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.