Defines a constant property that is initialized only when first accessed
name of the property
function called when the property is accessed the first time
Optional
target
const obj = {};defineLazyConstant(obj, 'config', function() { return loadConfigurationFile();});// config is loaded only when first accessedconsole.log(obj.config); // Loads and returns the configobj.config = {}; // Will not change the value Copy
const obj = {};defineLazyConstant(obj, 'config', function() { return loadConfigurationFile();});// config is loaded only when first accessedconsole.log(obj.config); // Loads and returns the configobj.config = {}; // Will not change the value
Defines a constant property that is initialized only when first accessed