Promises syntax that I learnt:
let p = new Promise(function (resolve, reject) {
let x = 20, y = 20;
if (x == y) {
resolve();
}
else {
reject();
}
})
p.then(function () {
console.log("that's correct");
})
.catch(function () {
console.log("that's not correct");
})
I don't even understand what happens here, the flow control of here. My mild guess is when resolve is called .then part happens, and when reject is called .catch part happens.
I've like read countless articles, banged my head against the wall but it's still not getting inside my head. I feel so dumb for asynchronous javascript.
Please help me understand the program flow step by step in more detail.