Defines a 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 = {};defineLazyProperty(obj, 'expensiveData', function() { return someExpensiveComputation();});// expensiveData is not computed until accessedconsole.log(obj.expensiveData); // Computes and returns the value Copy
const obj = {};defineLazyProperty(obj, 'expensiveData', function() { return someExpensiveComputation();});// expensiveData is not computed until accessedconsole.log(obj.expensiveData); // Computes and returns the value
Defines a property that is initialized only when first accessed