Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myPromise(t) {
- return new Promise((r) => {
- setTimeout(() => {
- r(t);
- }, t);
- });
- }
- const arr = [myPromise(2000), myPromise(500), myPromise(400)]; // iterable object
- (async () => {
- for await (const v of arr) { // iterates over the arr
- console.log(v);
- }
- })();
- // 2000, 500, 400
Add Comment
Please, Sign In to add comment