Reputation: 1818
I have an requirement where I need to return function start <function code> function end
to be the output of toString function get invoked on any function.
Upvotes: 0
Views: 672
Reputation: 4738
This would output function start and function end wrapped around the source code of the function's source itself. If you don't want the source, simply remove it.
(function(){
var j=Function.prototype.toString;//copy of native toString;
Function.prototype.toString=function()
{
return '//function start\n'+j.call(this)+'\n//function end';
};
})();
testy=function(a,b)
{
return a+b;
};
alert(testy);
Upvotes: 1