Asynchronous JavaScript(비동기 자바스크립트)
1. Promise
let p = new Promise((resolve, reject) => {
let a = 1 + 1;
if(a === 2) {
// resolve
resolve("Success");
} else {
// reject
reject("Failed");
}
})
// resolve
p.then((message) => {
console.log("This is in the then " + message);
// reject
}).catch((message) => {
console.log("This in in the catch " + message);
})
// This is in the then Success1️⃣ Callback
2️⃣ Promise
Promise 이용하기
2. Async/ Await
1️⃣ Promise
2️⃣ Async/ Await
Last updated