Factory Functions & Singleton Pattern

What's the main benefit of refactoring to use a factory function here?
// Before
const car1 = {type: 'Sedan', color: 'blue', engineSize: 2.0};
const car2 = {type: 'SUV', color: 'red', engineSize: 3.0};
const car3 = {type: 'Sedan', color: 'black', engineSize: 1.8};

// After
function createCar(type, color, engineSize) {
  return {type, color, engineSize};
}

const car1 = createCar('Sedan', 'blue', 2.0);
const car2 = createCar('SUV', 'red', 3.0);
const car3 = createCar('Sedan', 'black', 1.8);
Next Question (22/32)