diff --git a/doc/playground.md b/doc/playground.md index e02e89c163..16acafde89 100644 --- a/doc/playground.md +++ b/doc/playground.md @@ -90,23 +90,27 @@ equivalent to ```javascript var foo = { get bar() { - if (this._barRan) return this._bar; - this._barRan = true; - return this._bar = complex(); + return Object.defineProperty(this, "bar", { + value: complex(), + enumerable: true, + configurable: true, + writable: true + }).bar; } }; class Foo { get bar() { - if (this._barRan) return this._bar; - this._barRan = true; - return this._bar = complex(); + return Object.defineProperty(this, "bar", { + value: complex(), + enumerable: true, + configurable: true, + writable: true + }).bar; } } ``` -**NOTE:** Memoised functions will return the result of the **first** execution, regardless of arguments. - ### This shorthand ```javascript