Guest User

Untitled

a guest
May 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. function myPromise(t) {
  2. return new Promise((r) => {
  3. setTimeout(() => {
  4. r(t);
  5. }, t);
  6. });
  7. }
  8.  
  9. const arr = [myPromise(2000), myPromise(500), myPromise(400)]; // iterable object
  10.  
  11. (async () => {
  12. for await (const v of arr) { // iterates over the arr
  13. console.log(v);
  14. }
  15. })();
  16.  
  17. // 2000, 500, 400
Add Comment
Please, Sign In to add comment