Skip to content

Commit 0dcfdc5

Browse files
committed
Optimize example
1 parent 849c9ae commit 0dcfdc5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

JavaScript/2-each-non-blocking.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
const numbers = new Array(1000).fill(1);
44

55
const each = (array, fn) => {
6-
let i = 0;
76
const last = array.length - 1;
87
const next = i => {
98
setTimeout(() => {
109
fn(array[i], i);
1110
if (i !== last) next(++i);
1211
}, 0);
1312
};
14-
next(i);
13+
next(0);
1514
};
1615

1716
let k = 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy