Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Created June 9, 2024 14:17
Show Gist options
  • Save ChrisMoney/afdc14d7a03048bf13598080d03075b7 to your computer and use it in GitHub Desktop.
Save ChrisMoney/afdc14d7a03048bf13598080d03075b7 to your computer and use it in GitHub Desktop.
Promise - Javascript
/*
A promise in JavaScript is an object that represents the eventual completion or failure of an asynchronous operation.
*/
new Promise((resolveOuter) => {
resolveOuter(
new Promise((resolveInner) => {
setTimeout(resolveInner, 1000);
}),
);
});
//************
const myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("foo");
}, 300);
});
myPromise
.then(handleFulfilledA, handleRejectedA)
.then(handleFulfilledB, handleRejectedB)
.then(handleFulfilledC, handleRejectedC);
// ******************************************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment