Skip to content

Commit 600cf8d

Browse files
committed
Optimize variables
1 parent bbae381 commit 600cf8d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

JavaScript/3-callback.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
'use strict';
22

33
const wrapFunction = fn => {
4-
console.log('Wrap function: ' + fn.name);
4+
console.log('Wrap function:', fn.name);
55
return (...args) => {
6-
console.log('Called wrapper for: ' + fn.name);
6+
console.log('Called wrapper for:', fn.name);
77
console.dir({ args });
88
if (args.length > 0) {
9-
let callback = args[args.length - 1];
9+
const callback = args[args.length - 1];
1010
if (typeof callback === 'function') {
1111
args[args.length - 1] = (...args) => {
12-
console.log('Callback: ' + fn.name);
12+
console.log('Callback:', fn.name);
1313
callback(...args);
1414
};
15-
} else {
16-
callback = null;
1715
}
1816
}
19-
console.log('Call: ' + fn.name);
17+
console.log('Call:', fn.name);
2018
console.dir(args);
2119
const result = fn(...args);
22-
console.log('Ended wrapper for: ' + fn.name);
20+
console.log('Ended wrapper for:', fn.name);
2321
console.dir({ result });
2422
return result;
2523
};

0 commit comments

Comments
 (0)