I have a function e.g.
var test = function () {alert(1);}
How can I get the body of this function?
I assume that the only way is to
2015 update
Upon revisiting the state of function decompilation, it can said that it's generally safe in certain well-considered use cases and enviroments (e.g: Node.js workers with user defined functions).
It should be put in the same bucket as eval, which is a powerful tool that has its place, but should only be used on rare occasions. Think twice, that's my only advice.
The conclusions from Kangax's new research:
"function decompilation" — a process of getting string representation of a Function object.
Function decompilation is generally recommended against, as it is a non-standard part of the language, and as a result, leads to code being non-interoperable and potentially error-prone.
@kangax on comp.lang.javascript