catch is executed only when any error occurred. It will considers the error only it occurred before its placement.
EX:constpromise=newPromise((resolve, reject) => {if (true) {resolve("Stuff worked"); } else {reject("Error: Something went wrong"); }});constpromise2=newPromise((resolve, reject) => {setTimeout(resolve,100,'HIII');});constpromise3=newPromise((resolve, reject) => {setTimeout(resolve,1000,'PROOKIE');});constpromise4=newPromise((resolve, reject) => {setTimeout(resolve,5000,'It is me you are loking for me?');});Promise.all([promise, promise2, promise3, promise4]).then(values =>console.log(values));// ["Stuff worked", "HIII", "PROOKIE", "It is me you are loking for me?"]
Promise all takes multiple promises in array and result will be array of all the results of all promises.
The result will be received only after all the promises execution is completed. If any one of them gets error, all process will be stopped.