Here is my problem, i have one object Car & theirs properties, i defined a method inside the object. but i think it is recommended to append this method to the object protytype, but why? what are the advantages and disadvantages? Thank you :)
What i did..
function Car (desc) {
this.desc = desc;
this.color = "red";
this.getInfo = function getInfo() {
return 'A ' + this.color + ' ' + this.desc + '.';
};
}
Recommended :
Car.prototype.getInfo = function() {
return 'A ' + this.color + ' ' + this.desc + '.';
};