I want to know how to convert a function\'s body into a string?
function A(){ alert(1); } output = eval(A).toString() // this will come with function A()
You could just stringify the function and extract the body by removing everything else:
A.toString().replace(/^function\s*\S+\s*\([^)]*\)\s*\{|\}$/g, "");
However, there is no good reason to do that and toString actually doesn't work in all environments.