I'm sure that I'm missing something but I don't understand why developers so often create new instances of Functions
. For example I see this basic concept in numerous tutorials.
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
var myCar = new Car("Toyota", "Tacoma", 1997);
console.log(myCar.make +" " +myCar.model +" " +myCar.year);
But if functions can be reused as many times as needed why create new instances?
This function appears to do the same thing and I can use it as many times as needed.
function Car(make, model, year) {
console.log(make +" " +model +" " +year);
}
car("Toyota", "Tacoma", 1997);
car("Honda", "Civic", 2005);
// etc etc...