177 questions
-1
votes
2
answers
93
views
Waiting for all side promises to finish before "then()" execution
In section then3 I want to generate promises with further operations on their content inside 2 "thens". In case they were fetches, I want to limit their start to for example 3 at once every ...
1
vote
1
answer
27
views
Angular: data not rendering correctly
people.
I have a Angular application which I am integrating with a node.js server. It works like this:
A service is injected in the component
The component calls the getAccountData() function from ...
0
votes
0
answers
28
views
How to wait for dynamically loaded external js file and then execute it's instance as a global variable [duplicate]
I'm trying to dynamically call external JS files. I'm using promise to wait for file to be loaded and then execute the code. How ever I don't want to run all the code inside positive promise. I'd like ...
4
votes
2
answers
93
views
Sequence of rejected promise with Promise.reject()
I am learning microtask queue and i have a simple question.
With the following code:
Promise.resolve().then(()=>console.log("Resolved1 Promise"));
Promise.reject().then(()=>console.log("...
0
votes
1
answer
81
views
Promises execution order in Microtask Queue
const p1 = new Promise((_, reject) => {
reject(1);
}).then((r)=>console.log(r)).catch((r)=>console.log(r));
const p2 = new Promise((resolve, _) => {
resolve(10);
}).then((r)=>...
0
votes
2
answers
92
views
Understanding Promise Chaining Internal Mechanics
I am learning promise chaining and I stumbled upon a doubt. Consider the below promise chain -
const myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("...
-1
votes
1
answer
114
views
Can clearTimeout prevent the execution of a callback which has already been moved to the callback queue?
Consider a scenario where I have two tasks -
Task 1 is a callback which is set to be executed after 1 sec using setTimeout.
Task 2 is a synchronous/blocking task which takes comparatively more time ...
2
votes
1
answer
55
views
Empty result using FileReader and promise
I am struggling a bit with asynchronous operations and Promises (a quite new concept to me) using FileReader. I have found a very interesting thread about it there, but can't make my script to work ...
0
votes
0
answers
30
views
Is an object returned by a call to an async (external) process fundamentally different from an object that is returned from a 'normal' function?
I am quite new to Javascript, with my main programming experience in assembly language programming of micro-controllers. It has taken quite some time to adjust to it having so many 'system calls', (to ...
-2
votes
2
answers
408
views
Is there a meaningful difference between an async IIFE and a new Promise? [duplicate]
Consider the following assignments:
const promise1 = (async () => {
await someAsyncFunction();
})();
const promise2 = new Promise(async resolve => {
await someAsyncFunction();
...
2
votes
1
answer
84
views
Nested asynchronous javascript (microtask and macrotasks queues)
Recently I've been given a following problem:
console.log("start");
const promise1 = Promise.resolve().then(() => {
console.log("promise1");
const timer2 = setTimeout(() => {
...
1
vote
1
answer
67
views
Explain the output of the following code by describing the micro task queue and call stack architecture
This is the code:
function SSD() {
console.log('SSD')
}
async function createData() {
let status = undefined
try {
const res = await fetch('https://api.github.com/users/Soumya-...
1
vote
0
answers
891
views
firefox failing a post request - NS_BINDING_ABORTED
My case - "form data to be auto saved before navigating to new page". Firefox is cancelling form post with "NS_BINDING_ABORTED" and navigating to new page. Body - onbeforeunload is ...
2
votes
1
answer
89
views
Passing a primitive to a then handler
This is an interesting observation that I have made when experimenting with promises in JS. Consider this code:
Promise.resolve(1).then(2).then(console.log);
This prints out 1 as its output. ...
2
votes
1
answer
191
views
Does JS event loop always prioritize microtask queue over macrotask queue? [duplicate]
I was recently watching a workshop video by Will Sentence on async javascript and I am having trouble understanding whether microtask queue always has priority over macrotask queue.
function display(...