You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Synchronous - line by line execution of code , can perform only 1 task at a time , single threaded
6
+
Asynchronous - different blocks of code is executed at the same time parallely, multi threaded, this is achieved using { Promises , Thenables } --> later replaced by {Async & Await}
7
+
8
+
much before promises callbacks where used .. branching multiple callbacks inside one another made i hard to follow the code known as callback hell --> to prevent this in ES6 Promises where introduced which where later replaced by Async & await */
9
+
10
+
/* How does a Promise work ?
11
+
a Promise has 3 States : Pending , Fulfilled , Rejected
12
+
a Promise is an object that will produce a single value sometime in future. If the promise is successfull it'll produce a resolved value else a rejected value.*/
13
+
14
+
/*Promise constructor accept a single parameter which is a function called executor that has 2 paramenters resolve, reject -
15
+
Syntax :
16
+
const myPromise = new Promise((resolve,reject)=>{
17
+
//conditions to resolve or reject a promise
18
+
})
19
+
here Again resolve & reject are functions which have optional parameter like resolve value & rejected reason respectively.
0 commit comments