Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top