I used the prototype mechanism several times when debugging a script that I couldn't easily change source code for. I just typed:
SomeClass.prototype.someMethod
Which outputs the methods source. Then you can add some debug code like console.log(xxx) or even fix a simple bug, copy the whole thing and set it again:
SomeClass.prototype.someMethod = function ...
Voila! Hot code push without an IDE. While that's obviously not ideal, it certainly works in some cases.
var cache = SomeClass.prototype.someMethod;
SomeClass.prototype.someMethod = function () {
debugger; // or `throw "stacktrace"`
cache.apply(this, arguments)
}
Inserts a stack trace right in the middle of executing someone else's code, which is nice for tracking down why/when that function gets called if documentation is poor, without changing functionality.
SomeClass.prototype.someMethod
Which outputs the methods source. Then you can add some debug code like console.log(xxx) or even fix a simple bug, copy the whole thing and set it again:
SomeClass.prototype.someMethod = function ...
Voila! Hot code push without an IDE. While that's obviously not ideal, it certainly works in some cases.