function Person()
{
this.name="Person"
}
Person.prototype.hi=function(){
alert("Hello! I'm"+this.name)
}
function Iwanttoinherit(){
...
}
What is the main difference in OOP inheriting between using
Iwanttoinherit.prototype=new Person()
and
Iwanttoinherit.prototype=Object.create(Person.protoype)
new Person()instead ofObject.create(...), any change to thePersonprototype will also change theIwanttoinheritprototype, but not the other way around. Any properties created/added in the Person constructor will also be a part of theIwanttoinheritprototype. If that's your intention, then that's the method you should use.