promise.js 256 B

12345678910111213141516
  1. // example of a promise
  2. async function example() {
  3. return new Promise((resolve) => {
  4. console.log('inside promise');
  5. resolve();
  6. });
  7. }
  8. async function init() {
  9. console.log('before promise');
  10. await example();
  11. console.log('after promise');
  12. }
  13. init();