Promise APIs

1. What are Promise APIs? Promise APIs are built-in JavaScript methods for handling multiple promises simultaneously, allowing for efficient management of asynchronous operations. These APIs provide a way to aggregate and manipulate promises, helping developers coordinate multiple asynchronous tasks with ease. 2. Promise.all() Promise.all() takes an iterable (usually an array) of promises and returns a single promise that resolves when all the promises in the iterable have resolved or rejects if any promise in the iterable rejects....

July 16, 2024 · 3 min

this keyword

1. This in Global Space In the global context, this refers to the global object. Browser: window Node.js: global console.log(this); // In a browser, logs the Window object 2. This Inside a Function In a regular function, this refers to the global object when called globally. When called as a method of an object, this refers to that object. function regularFunction() { console.log(this); // Logs global object } regularFunction(); const obj = { method: function () { console....

July 15, 2024 · 2 min