Last active
February 14, 2017 14:20
-
-
Save jtrussell/33581c73f4c783ea7257a8fc4e28dfa0 to your computer and use it in GitHub Desktop.
Async/Await boilerplate for jsbin
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <script src='https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser-polyfill.min.js'></script> | |
| </head> | |
| <body> | |
| <p>Change JavaScript to ES6 / Babel</p> | |
| </body> | |
| </html> |
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
| // noprotect | |
| console.clear() | |
| const p = new Promise((resolve, reject) => { | |
| setTimeout(() => { | |
| resolve(5) | |
| }) | |
| }) | |
| async function fn() { | |
| const val = await p | |
| console.log(val) | |
| } | |
| const fn2 = async () => { | |
| const val = await p | |
| console.log(val) | |
| } | |
| fn() | |
| fn2() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment