Skip to content

Instantly share code, notes, and snippets.

@nikshinde-7
Created September 23, 2022 12:36
Show Gist options
  • Save nikshinde-7/6ec4102a5e21f9983fcd46b6840bf715 to your computer and use it in GitHub Desktop.
Save nikshinde-7/6ec4102a5e21f9983fcd46b6840bf715 to your computer and use it in GitHub Desktop.
let promise = Promise.resolve(1)
let nestedPromise1 = (x) => Promise.resolve(x * 2)
let nestedPromise2 = (x) => Promise.resolve(x + 6)
const firstNestingResult = await promise.then(nestedPromise1).then(nestedPromise2);
const secondNestingResult = await promise.then((x) => nestedPromise1(x).then(nestedPromise2));
console.log(firstNestingResult == secondNestingResult);
// Should log as true ✅
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment