Defines a lazy property on a class prototype
name of the property
function called when the property is accessed the first time
Optional
target
class User { constructor(id) { this.id = id; }}definePrototypeLazyProperty(User, 'details', function() { return fetchUserDetails(this.id);});const user = new User(1);// details are fetched only when accessedconsole.log(user.details); // Fetches and returns user details Copy
class User { constructor(id) { this.id = id; }}definePrototypeLazyProperty(User, 'details', function() { return fetchUserDetails(this.id);});const user = new User(1);// details are fetched only when accessedconsole.log(user.details); // Fetches and returns user details
Defines a lazy property on a class prototype