Follow us on: facebook twitter linkedin

PROGRAMING

Promise in Javascript

Post by : John Deo
Post date: 2024-09-16 11:27:49

Read time : 5 minute
Total views: 164 times
hero-img

Whats Promise in Javascript?

Promise is a new feature in Javascript for achieve asynchronous programming, which one invented at ES6.

 

Is Promise necessary?

Yes, to make program/application faster and helps improve performance by allowing handle multiple tasks simultaneously without waiting each one to complete.

 

How to use Promise?

There is a several way to use Promise. 

Suppose u have two function one is imageHandling and another one is videoHandling. Lets create first promise object by using new Promise. Promise class accept an anonymous function with two parameter first one indicate successful and second one failed operation. In the anonymous function write imageHandling code.  Next u should access then method by using promise object and handle respose. Same way write videoHandling code with another promise object.

Share by:

Keep exploring

Read what excites, achieves and moves us Read what excites, achieves and moves us