I now in javascript. I have a qustion about inhertants by prototype. How can takes a year with out use proto I have function Vehicle
function Vehicle(name,color,year){
this.name=name;
this.color=color;
this.year=year;
};
and function liveTime
Vehicle.prototype.liveTime=function(){
return new Date().getFullYear() -this.year;
};
we can inhertans by prototybe (BUT prototype is a property of a Function object. It is the prototype of objects constructed by that function.)
here we can inhertance by it
function Vehicle(name,color,year){
this.name=name;
this.color=color;
this.year=year;
};
Vehicle.prototype.liveTime=function(){
return new Date().getFullYear() -this.year;
};
var car= new Vehicle('y','red',2000);
console.log(car.liveTime());
The Qustion is why can inhertans by prototype without use proto