Skip to main content Skip to main navigation Skip to search Skip to footer

HCL Technologies

Javascript Promises: An Alternative Way to Asynchronous Call

Javascript Promises: An Alternative Way to Asynchronous Call

JavaScript Promises represents a significant shift in JavaScript programing, crafted around the completion or failure of asynchronous tasks in an intuitive manner.

A promise can be any of three states - unfulfilled (or pending), fulfilled, and failed (or rejected).

JavaScript Promises tracks asynchronous calls in a more robust and orderly fashion, replacing the asynchronous use of callbacks along with offering further additional benefits. By eliminating callback parameters, Promises aid in handling errors and writing cleaner codes without modifying the underlying architecture.

The Promise constructor is central to JavaScript Promises, creating an object by passing anonymous function with two parameters- resolve and reject method. A Promise object starts out with a state of pending, to indicate the asynchronous JavaScript code its monitoring has neither completed or failed.

While promise APIs vary according to language, Asynchronous JavaScript is aligned with the Promises/A+ proposed standard. EcmaScript 6 is slated to provide promises as a first-class language feature, and will be based on the Promises/A+ proposal.

 

DOWNLOAD THE WHITEPAPER

Contact Us
MAX CHARACTERS: 10,000

We will treat any information you submit with us as confidential.

We will treat any information you submit with us as confidential.