Last active
July 1, 2021 08:53
-
-
Save sorie/cf20db57ce635c75ce57e941c23fd076 to your computer and use it in GitHub Desktop.
promise
This file contains 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
/** | |
1. 프로미스를 반환할 수도 있다. | |
2. then후에 반아오는 변수가 하나일 경우는 생략할 수 있다. | |
**/ | |
const getHen = () => | |
new Promise((resolve, reject) => { | |
setTimeout(() => resolve('닭'), 1000); | |
}); | |
const getEgg = hen => | |
new Promise((resolve, reject) => { | |
setTimeout(() => resolve(`${hen} => 알`), 1000); | |
}); | |
get cook = egg => | |
new Promise((resolve, reject) => { | |
setTimeout(() => resolve(`${egg} => 후라이`), 1000); | |
}); | |
getHen() | |
.then(getEgg) //생략전 : .then(hen => getEgg(hen)) | |
.then(cook) | |
.then(console.log); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment