Function.prototype.toString to discover function dependencies

Brendan Eich brendan at
Mon Sep 20 14:47:01 PDT 2010

Lars Hansen, back a few years and based on his Opera experience developing Futhark, said that EBay (at least -- possibly other sites) used Function.prototype.toString to decompile a function, edit the source with string and regexp hacks, and recompile with Function (or possibly eval), for self-modifying code in JS.

This means web compatibility rules out dropping high-fidelity toString on function objects just because the implementation is on a memory-poor device. If too memory-poor, no EBay for you! :-P


On Sep 15, 2010, at 8:04 PM, Erik Arvidsson wrote:

> As far as I remember some Opera mobile versions don't return the code
> in Function.prototype.toString.
> A lot of JS frameworks today use the Function.prototype.toString to
> find references to super/base but they do fallback on slower paths if
> the toString method does not provide the code of the function.
> -- 
> erik
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list