something is not totally make sense in JS constructors. when I doing something like this:
function extends(child, parent) {
child.prototype = Object.create(parent.prototype);
child.prototype.constructor = child;
};
the "constructor" is never called. meaning, the "child" function does called, because it the one we doing "new child()". but if I am doing something like this:
function extends(child, parent) {
child.prototype = Object.create(parent.prototype);
child.prototype.constructor = function() {
alert("test");};
};
the "alert" is never fire because the real "child" function is called any way.
why is that? how can I override the constructor to be what I want ?