2010-06-02 00:00:00 +0100 by Alex R. Young

I just finished reading about Angus Croll's
tracer utility -- a tiny pure JavaScript method tracer. It traverses prototype
chains and wraps each method in a new function that calls the tracer's

To understand this, remember that functions on objects can be iterated
over. Also recall that functions in JavaScript are first class objects,
which means they can be decorated with properties. Combining these two
facts allows object methods to be iterated over and safely modified to
call external code.

This can even be done recursively:

tracer.traceAll(jQuery, true)
>> tracing init
>> tracing size
>> tracing toArray
// ...

The source code is in the article: A tracer utility in