Skip to content

Commit 18534d3

Browse files
committed
Clearer CachingDecorator comments
- comments are in pairs. The first of the pair talks about what happened "caching" and the second pair talks about what was alerted "the same". This is confusing. - changed comment so both lines tell the reader what happened and what result was returned.
1 parent 97ef862 commit 18534d3

File tree

1 file changed

+4
-4
lines changed
  • 1-js/06-advanced-functions/09-call-apply-decorators

1 file changed

+4
-4
lines changed

1-js/06-advanced-functions/09-call-apply-decorators/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ function cachingDecorator(func) {
3636

3737
slow = cachingDecorator(slow);
3838

39-
alert( slow(1) ); // slow(1) is cached
40-
alert( "Again: " + slow(1) ); // the same
39+
alert( slow(1) ); // slow(1) is cached and the result returned
40+
alert( "Again: " + slow(1) ); // slow(1) result returned from cache
4141

42-
alert( slow(2) ); // slow(2) is cached
43-
alert( "Again: " + slow(2) ); // the same as the previous line
42+
alert( slow(2) ); // slow(2) is cached and the result returned
43+
alert( "Again: " + slow(2) ); // slow(2) result returned from cache
4444
```
4545

4646
In the code above `cachingDecorator` is a *decorator*: a special function that takes another function and alters its behavior.

0 commit comments

Comments
 (0)