Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top