I tried to write same asynchronous code with the use of
callbacks
The traditional methodPromises
ES6 introduced promises using which we can make asynchronous calls and use.then()
and.catch()
on the resolved or rejected the promise respectively.async-await
ES8 introducedasync
functions using witch we can resolve any promise using theawait
keyword.
You can run this code inside your browser console or using Node.js locally on your machine.
This code is for my refrence only and might not make sense to you at all ๐