Outbound Link Summary:
1 month ago
p3k dots

The lazy-loading property pattern in JavaScript (via javascriptweekly.com).

const object = {
    get data() {
        const actualData = someExpensiveComputation();

        Object.defineProperty(this, "data", {
            value: actualData,
            writable: false,
            configurable: false,
            enumerable: false
        });

        return actualData;
    }
};