Skip to content

Instantly share code, notes, and snippets.

@JesterXL
Last active October 31, 2022 16:02
Show Gist options
  • Save JesterXL/7f066f5ffc4a8ab64541513f1357a65e to your computer and use it in GitHub Desktop.
Save JesterXL/7f066f5ffc4a8ab64541513f1357a65e to your computer and use it in GitHub Desktop.
Example of using Array Destructuring for Promise.all.
Promise.all([
someThingThatReturnsAPromise(),
otherThingThatReturnsAPromise(),
lastThingThatReturnsAPromise()
])
.then( results =>
{
// this...
const [first, second, third] = results;
// ... instead of
// const first = results[0].result;
// const second = results[1].result;
// const third = results[2].result;
});
@JesterXL
Copy link
Author

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