Hey, so I'm not entirely sure this is possible, but I am curious if it is possible to hack the definitions of "undefined" objects. Primarily, the purpose of this is to prevent errors from launching when doing a .replace on an object that is undefined. Is it possible to go into the "back end" (is there even such a thing??) and add a method to the undefined object (if that is even defined in the first place??). Essentially something along the likes of
undefined.prototype.replace = function(v,r){ return false };
Obviously this works with String or Object, but undefined, seems to, by nature, have no definition. But it feels like you should still be able to mess with it, since javascript has it as an available end result.
Thanks for your time! I'm really curious as to what will pop up here!
EDIT: The main issue is that I am co-developing with 8 other developers with versioning control, and some of the newer people that come in aren't familiar javascript (or good error handling for that matter), so I wanted to make a global handler for minute errors that can receive default returns if necessary. Doesn't look like this idea will work. Maybe a global try and catch scenario?