Factory & Constructor Functions

What problem does this initialization pattern solve?
const createService = (() => {
  let instance;
  
  return (config) => {
    if (instance) {
      return Object.freeze({ ...instance });
    }
    
    instance = {
      apiKey: config.apiKey,
      endpoint: config.endpoint,
      request(url) {
        // Make API request
      }
    };
    
    return Object.freeze({ ...instance });
  };
})();
Next Question (17/20)