Jan 3, 2024
What is providing CarFactory as constructor function, which creates an instance with a single createCar method, good for? One is in need of exactly a single factory-function which creates Car instances. Thus, the following code already is sufficient enough ...
function createCar(model, year) {
return new Car(model, year);
}