I am new to programming and JavaScript and I don’t understand those “ resolve “and “ reject” arguments of the code below.
const myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('foo');
}, 300);
});
myPromise
.then(handleResolvedA, handleRejectedA)
.then(handleResolvedB, handleRejectedB)
.then(handleResolvedC, handleRejectedC);
Tutorials say Promise class takes two arguments which are functions. But where are resolve and reject functions ??? If it is written in this promise class , I think those functions will be written like myPromise.resolve ??
I also wanna know if promise class always have to take resolve and reject as arguments ? It can’t be resolve1 and resolve2 ?? Those names are registered or something???
resolve and reject come from nowhere and I am confused. I hope someone help me ;( thanks