Skip to content

Commit d9e4011

Browse files
committed
Example optimizations
1 parent 926f381 commit d9e4011

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

JavaScript/3-closure.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ function maybe(x) {
1212

1313
// Usage
1414

15-
/*maybe(5)()(console.log);
15+
maybe(5)()(console.log);
1616
maybe(5)(x => ++x)(console.log);
1717
maybe(5)(x => x * 2)(console.log);
18-
maybe(null)(x => x * 2)(console.log);*/
19-
maybe(5)(x => x * 2)()(console.log);
18+
maybe(null)(x => x * 2)(console.log);
19+
maybe(5)(x => x * 2)(x => ++x)(console.log);

JavaScript/8-counter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ const counter = initial => {
1717

1818
Counter.prototype.on = function(n, callback) {
1919
const event = this.events[n];
20-
if (event) event.push(callback); else this.events[n] = [callback];
20+
if (event) event.push(callback);
21+
else this.events[n] = [callback];
2122
return this(0);
2223
};
2324

2425
// Usage
2526

2627
const c = counter(10);
2728
c.on(5, val => console.log('Counter > 5, value:', val));
28-
c.on(5, val => console.log('Counter > 5, value:', val));
2929
c.on(25, val => console.log('Counter > 25, value:', val));
3030
c(5);
3131
setTimeout(() => c(15), 100);

0 commit comments

Comments
 (0)