3 ms·
In the prototype example [1], could someone explain the point or at least the effect of setting Bar.prototype.constructor = Bar? 1. http://bonsaiden.github.com
by andreyf 16y ago
In the prototype example [1], could someone explain the point or at least the effect of setting Bar.prototype.constructor = Bar?
1. http://bonsaiden.github.com/JavaScript-Garden/#prototype http://bonsaiden.github.com/JavaScript-Garden/#prototype
- nfriedly 16y agoA couple of lines up you see this: Bar.prototype = new Foo(); Then, Bar.prototype.constructor == Foo() So when you create a new instance of Bar, it's constructor still appears to be Foo even though it really isn't. Setting the prototype.constructor fixes that.