I am wondering whats the difference between inheritFrom and the prototype when defining inheritance in Javascript.
function classA{}
classA.name="abc";
classA.functionName=function(){
alert("Function Name Alert");
}
function classB{ }
Whats the difference in the below codes?
classB.prototype=classA();
and
classB.prototype.inheritFrom(classA);
B.prototype.inheritFrom(A)is not standard JavaScript, whereasB.prototype = new Ais standard JavaScript. I suggest learning the ins and outs of JavaScript and embracing the prototype. You’ll be better off for knowing it. It’s really not too difficult: