Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
50 views

callback queue , call stack and registered event like setTimeout

what happens if any event is register (like setTimeout) but it takes more time (assume 5,6 min ), and currently call stack and callback queue is completed all task and it is empty, so the program is ...
Mayank's user avatar
  • 11
-1 votes
1 answer
52 views

Problem with Execution order i would guess

im loosing my mind! I try to get data from a form and pass it to a php script that puts the data in a csv file and into a database. This Works, however i am trying to validate the Transmission of the ...
360Bits's user avatar
  • 31
4 votes
1 answer
808 views

How does Wasm code run in browsers and how does it interact with JavaScript

I'm curious about how WebAssembly (Wasm) code operates in the browser. I understand that JavaScript code in the browser is executed by the JavaScript engine, but I'm unsure about who executes the Wasm ...
Live's user avatar
  • 41
0 votes
1 answer
131 views

Does JavaScript have an Event table?

I read an article on Medium that said that "JavaScript has an event table that keeps tracks of all the events that will be executed asynchronously maybe after some time interval or after the ...
Montin's user avatar
  • 45
0 votes
1 answer
52 views

Why don't I see task queue bunch up?

I am reading and conversing with chatGPT about what exactly setTimeout and setInterval do. As I understand it the main JavaScript execution thread sends the Web Timer API a callback function and an ...
qhuboo's user avatar
  • 37
1 vote
0 answers
89 views

Order of processing microtasks in JavaScript [duplicate]

I’m solving an event loop problem in Javascript and I can’t figure out why the output order is 2, 1, and not 1, 2. f1(); Promise.resolve().then(() => { console.log(2); }); async function f2() { ...
Party Favor's user avatar
1 vote
1 answer
78 views

why setImmediate function executes after setTimeout

setImmediate(() => { console.log("set immediate function calling") }) setTimeout(() => { console.log("setTime out function") }, 1000) for (let i = 0; i <= ...
Manish Rai's user avatar
0 votes
3 answers
251 views

Javascript maximum call stack size even though recursive function call itself with an accumulator

I have an object whose value can be any type. const data = { a: { aa: 50, ab: 'hello', ac: 'xx_1' }, b: 50, c: [ { ca: 100, cb: 'by', cc: 'xx_2' }, { ca: 101, cb: 'by1', cc: '...
Loutag's user avatar
  • 83
1 vote
1 answer
94 views

Why does console.trace() show a growing stack trace when using event listeners with { once: true } option?

I have this inline js code. let btn = document.querySelector("button"); btn.addEventListener("click", foo, { once: true }); function foo() { btn.addEventListener("click", bar, { once: true }); ...
LNTR's user avatar
  • 108
1 vote
0 answers
481 views

Uncaught RangeError: Maximum call stack size exceeded (functionjs.js)

I'm trying to build a recruitment management website (nodejs), but when I'm almost done I get this error: Uncaught RangeError: Maximum call stack size exceeded. functionjs.js Here is my functionjs.js ...
Cmint's user avatar
  • 19
0 votes
1 answer
161 views

Random placement of items on canvas without overlap

I'm trying to randomly place a number of items (sprites) onto a canvas element without any overlap. I'm using a seeded random number so that I can get consistent placement. However I'm running into a ...
TommyBs's user avatar
  • 9,606
-1 votes
1 answer
88 views

how to make a syncrounous function like writefilesync not using callbacks, nor promises

first of all let me say i'm not asking anything about async/await or promises, i know these concepets, a also know that i can use top-level awaits but i want to make "a single function" to ...
TechDogLover OR kiaNasirzadeh's user avatar
0 votes
0 answers
164 views

Can somebody explain how this code is executed in relation to the call stack and the event loop?

I have created this snippet which I am trying to figure out how it's working the way it's working. function fetch() { console.log("Fetch start"); return new Promise(resolve => { ...
kekerinho's user avatar
1 vote
1 answer
49 views

If Array.prototype.map is not in the call stack, how exactly JavaScript knows to not run any other code before its iteration is over?

function callback(x) { // also tried debugger to find .map in the call stack console.trace(); return 2*x; } [1,2,3].map(callback); console.log('Next line of code'); console What I know about ...
Nick_the_Slasher_McGurk's user avatar
3 votes
1 answer
611 views

Does the both functions parent and asynchronous child get re-pushed to call stack from task queue on completion of async code of child function?

What i all know about call stack is: If there is only one function being called it will be pushed to call stack and removed when its job is done or otherwise return statement is encountered. If one ...
Yogesh Kakde's user avatar
0 votes
1 answer
503 views

RangeError: Maximum Call Stack Size Exceeded in JS when generating 24 Random Numbers [duplicate]

I am working on a project in JavaScript where I must generate 24 random and different numbers from 1-24. Whenever I run this code, I get this error in Safari, Firefox, and Chrome RangeError: Maximum ...
David Kolenda's user avatar
0 votes
0 answers
27 views

How do I find the number-palindrome if a large number causes the size exceeded collstack to overflow?

I try to find a palindrome number, but if the number I pass is too big, then the call stack overflows. How can this be fixed so that the function can return larger numbers? (function () { ...
Dunker's user avatar
  • 1
1 vote
1 answer
127 views

Why doesn't the Event Loop retrieve from the Callback Queue when the Call Stack is empty?

I am aware that the Event Loop takes the first callback from the Callback Queue when the Call Stack is empty. With this premise, why does the below code execute sync2() before the setTimeouts' ...
Kakamotobi's user avatar
  • 1,907
0 votes
0 answers
36 views

Recursion Error: Maximum call stack size exceeded for checking if a negative number exists in an array

I have a recursion methods to check if a generated random number exists in the idNum array. My code is below. I'm getting a RangeError: Maximum call stack size exceeded error in the recursion and not ...
sk_225's user avatar
  • 427
0 votes
0 answers
23 views

Run time-consuming function with Promises without blocking runtime [duplicate]

I'm trying to understand how to use time consuming function with Promises. I have some nonsense, but time consuming function computation() (that I create for demonstration purpose), that would need 3-...
VelikiyMalchik's user avatar
2 votes
3 answers
441 views

when is the call stack really empty?

https://promisesaplus.com/#point-34 onFulfilled or onRejected must not be called until the execution context stack contains only platform code. Promises (then(), catch(), finally()) and async ...
user avatar
0 votes
1 answer
1k views

LibUV NodeJS handle synchronous or asynchronous tasks?

I'm Nodejs beginner. I have been reading some documents and posts on Google and as far as I know, LibUV is used to handle asynchronous tasks. However, when I came across a post recently, the author ...
Simba's user avatar
  • 136
0 votes
0 answers
48 views

Why don't anonymous functions change context - Does it have to do with the call stack? [duplicate]

This code keeps the context in window: const a = function () { console.log(this);} //window And this code changes the context to a2: const a3 = { anyFunction: () => { console.log(this) } // ...
Ric's user avatar
  • 199
0 votes
0 answers
96 views

In Javascript, is it possible to communicate to workers while inside while-loop?

I have a recursive calculation, which I handle using a manual call stack. var stack = initialListOfTasks(); while (stack.length > 0) { var todo = stack.shift(); performTask(stack, todo); }...
Jan Mulder's user avatar
0 votes
1 answer
36 views

JavaScript - result undefined - forcing one method to complete before another?

I have the following NodeJS code running in an AWS Lambda: const https = require('https'); exports.handler = async event => { try { const currentWeekNumber = getWeekNumber(new Date(Date....
java12399900's user avatar
  • 1,591
0 votes
2 answers
2k views

What is the difference between call stack and task queue in javaScript(event-loop)?

I am confuse in differentiating between call stack and task queue in the context of event loop. Call stack -->Every time a script or function calls a function, it's added to the top of the call ...
Hemant Aher's user avatar
3 votes
3 answers
813 views

Do eventlisteners callback functions go into callback queue?

I think depending on my understand that callback functions are placed in the callback queue and don't execute until callstack is empty, so in the following code, why does the callback function of the ...
Aya Othman's user avatar
0 votes
1 answer
68 views

How to get call stack in VSC debugger? console.trace() is undefined

If I'm paused in the VSC debugger I can't get the call stack with console.trace().
Dashiell Rose Bark-Huss's user avatar
0 votes
2 answers
66 views

How can I prevent a RangeError while running an algorithm that finds all permutations of a given word?

I've built a thesaurus-application in React that fetches data from a web-dictionary API and renders definitions, synonyms, and antonyms as collapsible lists when a user searches a word. I'd like to ...
Neuroneer's user avatar
-1 votes
1 answer
83 views

How do I prevent an infinite call stack from occurring when generating a large binary grid?

I'm working on a web-app implementation of Binary Sudoku that recursively generates random, solved boards, after which it reduces the amount of tiles on the grid down to a valid starting point for ...
Neuroneer's user avatar
0 votes
2 answers
170 views

quickSort javaScript throwing Maximum call stack size exceeded

why is this function throwing error I am trying to sort array using quickSort with a recursion approach here I am using the last element in the array as a pivot let array = [1,0,123,1,3,12,2,45,6] ...
Prakash Reddy's user avatar
-1 votes
1 answer
75 views

why my async code is not executing inspite of being the free call stack

As per my knowledge async code is executed when the call stack is empty and execution of the async code is finished in web API But In a given code why my async code which is setTimeout function and ...
MohishKhadse55's user avatar
0 votes
1 answer
2k views

Is async in javascript concurrent or parallel?

JavaScript code runs on a single thread, in event loop when method push to web apis return callback function to queue, listener queue and callstack is empty push callback function execute it in ...
DANG PHONG's user avatar
1 vote
2 answers
535 views

How does JS know where to continue in the Call Stack?

I'm trying to understand how the Call Stack works after each function is popped. For example: function inner() { console.log("what happens after inner() is popped from Call Stack?"); } ...
Chloé's user avatar
  • 21
0 votes
2 answers
27k views

I am getting RangeError: Maximum call stack size exceeded error in Javascript

I am trying to solve a problem of leetcode through recursion but I am getting an error saying RangeError: Maximum call stack size exceeded maybe I am doing something wrong. Problem: Write an algorithm ...
Harsh Mishra's user avatar
0 votes
1 answer
1k views

Maximum call stack size exceeded for large iterators

I'm trying to convert an iterator to an array. The iterator is the result of calling matchAll on a very long string. The iterator (I assume) has many matches within the string. First I tried it with ...
Infamous911's user avatar
  • 1,531
0 votes
2 answers
205 views

Where will this callback function be registered in Node.js and how does it behave?

const add = (n1, n2, callback) => { setTimeout(() => { const sum = n1 + n2 callback(sum) },2000)} add(1, 4, (sum) => { console.log(sum) // Should print: 5 }) I ...
Zenast's user avatar
  • 61
1 vote
2 answers
156 views

how to avoid recursion or to fix the problem?

Teaching JS trying to do a ticatactoe game and got a problem with recursion, specifically with 'Maximum call stack size exceeded'. When I try to make a random move by the computer player I make a ...
justice81's user avatar
0 votes
0 answers
162 views

Merge Sort question: Maximum call stack exceeded, avoided infinite recursion

Unable to get a terminal output because of error: Uncaught RangeError: Maximum call stack size exceeded. Tried to look at similar questions on stackoverflow, like this Maximum call stack size exceeded ...
Shawn Oh's user avatar
1 vote
0 answers
323 views

Max call stack is greater in while loop

all. Would be grateful if someone could clarify the following. We have a basic factorial function and a for loop with a try catch block which runs the function until error "Maximum call stack ...
Katya Horton's user avatar
1 vote
1 answer
80 views

Javascript - How to execute a function on a given time ? (with variable time periods)

I have to make a request to the backend server to retrieve some data, and inside the response comes the hour of the day that I have to make the request again. For example: I make the request at 12:00 ...
TAVentura's user avatar
0 votes
0 answers
952 views

Maximum call stack size exceeded due to recursive function

I'm trying to populate data from an array through a recursive function, and this function would get called upon each time the data or search value is updated. I understand that to avoid call stack ...
Cedric Woo's user avatar
1 vote
0 answers
446 views

Why are primitives types stored in call stack instead of the heap?

My understanding is that call stack is supposed to keep track of which codes are getting executed, and memory heap is where the data is stored. However, I recently discovered that call stack also ...
Sugarpearl's user avatar
0 votes
0 answers
244 views

JavaScript: What is the data structure for the call stack?

I'm writing an article about JS concurrency model and event loop. I've read many (even internally) conflicting articles regarding the data structures of the call stack and Execution Contexts. A ...
André Casal's user avatar
  • 1,190
4 votes
3 answers
281 views

Why are function expressions not included in the variable object of the Execution Context?

While going through the Execution Context part of the JavaScript.The Core. (1st ed.) by Dmitry Soshnikov, I came across this line that explicitly says that function expressions are not included in the ...
amkhrjee's user avatar
  • 936
6 votes
2 answers
2k views

Callback function executing in the call stack even when it's not empty

When the click event is fired from the mouse, it behaves as expected: First the listener 1 is pushed into the stack where it queues promise 1 in Microtask Queue(or Job Queue). When listener 1 is ...
Onex's user avatar
  • 73
0 votes
0 answers
345 views

get the function caller in javascript

I have a function createStuff which gets called when the html body is loaded inside the function is a event listener btn.addEventListener("click", notes); which calls the notes function ...
herbert mühlex's user avatar
1 vote
1 answer
424 views

Recursion in JavaScript question- how is the position of console.log here affecting the order in which values are returned?

I'm fairly new to programming and I'm learning about basic recursion for the first time. A result I just got playing around with a practice question in JavaScript is really baking my noodle. function ...
TheGuntz's user avatar
0 votes
2 answers
3k views

why setInterval inside useEffect hook in React keeps running?

I have this React component import React, {useEffect, useRef, useState} from 'react'; export default function MyD3(props) { const [count, setCount] = useState(0); useEffect(() => { ...
Alessandro Sassi's user avatar
0 votes
1 answer
237 views

Is some wrong with this call stack in this react component?

I was trying to make a stopwatch counter however when I call the "startTimer" function, the setInterval function is fired before the setStartTime (is fired after I click the start button for ...
Capt.Auh3b's user avatar