Skip to content

Commit 2557a9f

Browse files
code : add comment about callback
1 parent c058fba commit 2557a9f

File tree

2 files changed

+46
-47
lines changed

2 files changed

+46
-47
lines changed

_6-2-프로미스 Promise.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* 2. 프로미스 : Promise */
2+
3+
new Promise((resolve, reject) => {
4+
console.log("콜백백님 한판해요") // 1
5+
resolve()
6+
})
7+
.then(() => {
8+
console.log("NAGA!") // 2
9+
})
10+
.catch(() => {
11+
console.log("오옹? 나이스!") // 2(에러시)
12+
})
13+
14+
15+
function f1() {
16+
return new Promise((r1, r2) => {
17+
setTimeout(() => {
18+
console.log("뭐드세요");
19+
r1();
20+
}, 1000);
21+
})
22+
}
23+
24+
f1()
25+
.then(() => f1())
26+
.then(() => {
27+
setTimeout(() => {
28+
console.log("뭐 드시냐고 세번째 물어봅니다.")
29+
}, 1000)
30+
})
31+
32+
33+
function bae() {
34+
return new Promise((resolve, reject) => {
35+
setTimeout(() => {
36+
console.log("배먹어 배!")
37+
setTimeout(() => {
38+
resolve()
39+
}, 1000)
40+
}, 4000)
41+
})
42+
}
43+
44+
bae().then(() => {
45+
console.log("얘 겨울배가 맛있단다")
46+
})

_6-JS 비동기 처리방식.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)