Created
January 26, 2018 06:02
-
-
Save ichiroku11/60d6cbbb23fe56f9982611514419500a to your computer and use it in GitHub Desktop.
Promiseのサンプル
This file contains hidden or 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
| // https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise | |
| // resolveとrejectは関数 | |
| const promise = new Promise((resolve, reject) => { | |
| // 3秒後にresolveする | |
| setTimeout(() => resolve(1), 3000); | |
| }); | |
| // resolveされたときのコールバック | |
| promise.then(value => console.log(value)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment