async function sequentialExecution() {
const result1 = await asyncTask1();
const result2 = await asyncTask2(result1);
const result3 = await asyncTask3(result2);
return result3;
}- 비동기 로직들을 동기 코드처럼 작성하는 방식
await키워드는 실행이 완료될 때까지 대기를 시키므로 실행 순서 보장
asyncTask1()
.then((result1) => asyncTask2(result1))
.then((result2) => asyncTask3(result2))
.catch((error) => console.error(error));const results = await Promise.all([asyncTask1(), asyncTask2(), asyncTask3()]);Promise.all()을 활용하면 결과는 정렬되지만 실행 순서는 병렬적