promise를 더욱 가독성있게!
function hello(){
return 'hello';
}
async function helloAsync(){
return 'hello Async;
}
console.log(hello()) //hello
console.log(helloAsync()) //Primise{<pending>}


function hello(){
return 'hello';
}
async function helloAsync(){
return 'hello Async';
}
helloAsync().then((res)=>{
console.log(res)
});


function delay(ms){
return new Promise((resolve) => {
setTimeout(resolve, ms)
});
}
async function helloAsync(){
return delay(3000).then(() => {
return'hello Async';
});
helloAsync().then((res)=>{
console.log(res)
});
function delay(ms){
return new Promise((resolve) => {
setTimeout(resolve, ms)
});
}
async function helloAsync(){
await delay(3000);
return'hello Async';
});
helloAsync().then((res)=>{
console.log(res)
});
function delay(ms){
return new Promise((resolve) => {
setTimeout(resolve, ms)
});
}
async function helloAsync(){
await delay(3000);
return'hello Async';
});
function main(){
const res = await helloAsync();
console.log(res);
});
}
main();