Skip to content

Instantly share code, notes, and snippets.

@DmitryMasley
Last active February 23, 2020 08:04
Show Gist options
  • Save DmitryMasley/1f16f7327c62daf411ef46d29cdd17cb to your computer and use it in GitHub Desktop.
Save DmitryMasley/1f16f7327c62daf411ef46d29cdd17cb to your computer and use it in GitHub Desktop.
const promise = new Promise((resolve) => resolve("John Smith"));
// what is the difference between these versions?
// is there incorrect syntax?
//1
promise
.then((name) => {
return `Hello, ${name}`
})
.then((message) => console.log(message));
//2
promise
.then(async (name) => {
return `Hello, ${name}`;
})
.then((message) => console.log(message));
//3
promise
.then((name) => {
return Promise.resolve(`Hello, ${name}`);
})
.then((message) => console.log(message));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment