Ques:- What are promises and async await in JavaScript
Asked In :-
Unyscape Infocom Pvt. Ltd., Medvarsity Online, Ziffity Solutions, LiteBreeze Infotech, CakeSoft Technologies, Sun Technology Integrators, Happiest Minds Technologies Pvt., Ray Business Technologies, XIPHIAS Software Technologies, Spark Infosys,
Right Answer:
Promises in JavaScript are objects that represent the eventual completion (or failure) of an asynchronous operation and its resulting value. They allow you to handle asynchronous code more easily by providing methods like `.then()` for success and `.catch()` for errors.
`async` and `await` are syntactic sugar built on top of promises. An `async` function always returns a promise, and within an `async` function, you can use `await` to pause execution until a promise is resolved, making the code easier to read and write as if it were synchronous.
Promises in JavaScript are objects that represent the eventual completion (or failure) of an asynchronous operation and its resulting value. They allow you to handle asynchronous code more easily by providing methods like `.then()` for success and `.catch()` for errors.
`async` and `await` are syntactic sugar built on top of promises. An `async` function always returns a promise, and within an `async` function, you can use `await` to pause execution until a promise is resolved, making the code easier to read and write as if it were synchronous.