Skip to content

Commit 35c0e5a

Browse files
authored
Update objects.md
1 parent 6b2dbdc commit 35c0e5a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

challenges/objects.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ The lookup happens at the object level initially and if the key is not found, pr
339339
const obj = {};
340340

341341
Object.defineProperty(obj, 'data', {
342-
_data: 0,
342+
_data: 0, // closure variable to hold the data
343343
get() {
344344
return this._data;
345345
},
@@ -349,6 +349,9 @@ Object.defineProperty(obj, 'data', {
349349
});
350350
```
351351

352+
###### Notes
353+
If the `this.data` is accessed directly, the function will call itself infinitely. Hence, we would require one more variable to store the data
354+
352355
###### References
353356
- https://javascript.info/property-accessors
354357

0 commit comments

Comments
 (0)