The Problem With Inheriting From Intrinsic Classes
As some readers may have discovered, using the inherit function to inherit from the intrinsic classes won't work. This is an irritation as it's often useful to inherit from these basic classes in order to develop various extensions that have extra behaviours, such as validation of values and specialized formatting.
for ( var i in String.prototype )
alert('String.prototype[' + i + '] = ' + String.prototype[i]);
Although results may vary, typically the methods and properties are not included.
It's not just that the methods are not enumerated, their implementations cannot be translated either. Consider the following code:
this.charAt = String.prototype.charAt;
var s = new MyString("hello");
Running the above code in Internet Explorer results in the letters 'o', 'b', 'j', 'e', 'c' and 't'; which are somewhat different to what might have been hoped for.
March 27, 2003
Revised: April 28, 2006