I'm trying to learn JS OOP, and there is this tutorial where we are given this code:
function extend(Child, Parent) {
var Temp = function() {};
Temp.prototype = Parent.prototype;
Child.prototype = new Temp();
Child.prototype.constructor = Child;
}
I want to know, why can't you just say:
function extend(Child, Parent) {
Child.prototype = Parent.prototype;
Child.prototype.constructor = Child;
}
And avoid the hassle of making an intermediary, sorry if this is obvious, I'm a beginner.