Skip to content

Commit bbae381

Browse files
committed
Optimize loops
1 parent c561bb3 commit bbae381

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

JavaScript/3-callback.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ const wrapFunction = fn => {
2727

2828
const cloneInterface = anInterface => {
2929
const clone = {};
30-
let key, fn;
31-
for (key in anInterface) {
32-
fn = anInterface[key];
30+
for (const key in anInterface) {
31+
const fn = anInterface[key];
3332
clone[key] = wrapFunction(fn);
3433
}
3534
return clone;

JavaScript/4-wrap-api.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ const wrapFunction = fn => {
1414

1515
const cloneInterface = anInterface => {
1616
const clone = {};
17-
let key, fn;
18-
for (key in anInterface) {
19-
fn = anInterface[key];
17+
for (const key in anInterface) {
18+
const fn = anInterface[key];
2019
clone[key] = wrapFunction(fn);
2120
}
2221
return clone;

0 commit comments

Comments
 (0)