object-properties
    Preparing search index...

    Function defineConstants

    • Defines multiple constant properties on an object at once

      Type Parameters

      • T
      • P extends Record<string, any>

      Parameters

      Returns Readonly<P> & T

      target

      const config = {};
      defineConstants(config, {
      API_URL: 'https://api.example.com',
      MAX_RETRIES: 3,
      TIMEOUT: 5000
      });

      config.API_URL = 'new-url'; // Will not change the value
      console.log(config.API_URL); // 'https://api.example.com'