Reputation: 3669
Nowadays, when you call a function's .toString()
, browsers return the function's original declaration.
But I remember that Firefox used to return an optimized version, eg.
function fn() {
return 2+3;
}
fn.toString() // Used to give: function fn() {return 5;}
On which browsers is it safe to use this feature?
Upvotes: 9
Views: 105
Reputation: 7680
From MDN:
Since Gecko 17.0 (Firefox 17 / Thunderbird 17 / SeaMonkey 2.14), Function.prototype.toString() has been implemented by saving the function's source. The decompiler was removed, so that the indentation parameter is not needed any more. See bug 761723 for more details.
Upvotes: 6