Skip to content

Instantly share code, notes, and snippets.

@colinta
Created September 29, 2020 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinta/c419958a2834ad6c1fbad61525d74fbb to your computer and use it in GitHub Desktop.
Save colinta/c419958a2834ad6c1fbad61525d74fbb to your computer and use it in GitHub Desktop.
async function foo() {
console.log('foo');
return 'foo';
}
function bar() {
return new Promise(resolve => {
console.log('bar');
resolve('bar');
});
}
const a = foo();
const b = bar();
@colinta
Copy link
Author

colinta commented Sep 29, 2020

node promises.js
foo
bar

@colinta
Copy link
Author

colinta commented Sep 29, 2020

https://www.javascriptjanuary.com/blog/the-promise-of-a-better-future#eagerness

Promises are eager. This means that when a new Promise is constructed, it immediately starts executing, attempting to resolve the asynchronous value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment