Last active
August 1, 2016 09:26
-
-
Save indatawetrust/b9d7a65103c12a80fd9cd00015c5ac45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function b(c) { | |
return new Promise((resolve,reject) => { | |
resolve(c * 2) | |
}) | |
} | |
const list = [] | |
async function a() { | |
for(let i=1;i<=5;i++){ | |
list.push(await b(i)) | |
} | |
return list | |
} | |
async function e() { | |
console.log(await a()) | |
} | |
e() | |
/* | |
log: | |
[2,4,6,8,10] | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function b(c) { | |
return new Promise((resolve,reject) => { | |
resolve(c) | |
}) | |
} | |
async function a() { | |
const d = await b("hi") | |
return d | |
} | |
async function e() { | |
console.log(await a()) | |
} | |
e() | |
/* | |
log: | |
hi | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment