You have a test function. This is instanceof Function and inherits from Function.prototype , so you can call test.bind , for example.
Then you set the "prototype" property of your function to an object that inherits from Function.prototype . This means that all test instances inherit from this object (and from Function.prototype):
var t = new test; t instanceof test; // => true t instanceof Function; // => true
Then you overwrite the test property on your own prototype object. You do this well, because function methods should only be called on functions (i.e. called objects):
>>> Function.prototype.bind.call({}) Unhandled Error: Function.prototype.bind: this object not callable
In your tests using console.log you apply the Function methods only to your test function, not to its instances. Good, because they will fail. Thus, I see no reason why any objects should inherit from Function - you cannot create functions that are not inherited directly from Function .
Bergi May 15 '12 at 11:21 2012-05-15 11:21
source share