I would recommend calling the vanilla toString function of the Function object to strengthen your function as follows:
Function.prototype.toString.call(yourFunctionHere);
This prints your function as you mentioned.
If you want to replace values ββlater, you can use replace in combination with the regular expression.
Like this:
function myFunction(param1){ alert(param1); } Function.prototype.toString.call(myFunction).replace(new RegExp('param1', 'g'), 'theParam');
This will give you the following:
"function myFunction(theParam){ alert(theParam); }"
JoschuaSchneider
source share