Linked Questions
12 questions linked to/from JavaScript setTimeout() won't wait to Execute?
99
votes
8
answers
59k
views
Why is the function executed immediately when I use setTimeout? [duplicate]
I'm trying to write simple code with a setTimeout, but the setTimeout just won't wait the time it's supposed to and the code executes immediately. What am I doing wrong?
setTimeout(testfunction(), ...
1
vote
3
answers
2k
views
My JavaScript function runs without being called [duplicate]
The function tablePush pushes an id to the table upon a click on an item.
However, it runs without a click and I don't understand why.
Here is my code:
function tablePush() {
console.log('OK');
...
5
votes
0
answers
21k
views
console.log() on setTimeout() JS [duplicate]
can someone help me understanding why this code:
for (var i =0; i < 2; i++) {
setTimeout(console.log(i), 0);
}
console.log("aaa");
Will write:
0
1
aaa
But that code:
for (var i ...
1
vote
1
answer
2k
views
node cron running automatically on start [duplicate]
I'm using https://www.npmjs.com/package/cron version is ^1.7.2. Normally it scheduled at 10:40 PM everyday and it works well on that part. The problem that i want to solve is when i run my code by ...
-1
votes
1
answer
1k
views
Polling Javascript [duplicate]
I'm trying to poll a NodeJs Server using the fetch function but the setInterval method is actually not working as expected (it runs only once and then stops).
window.onload = () => {
let label ...
1
vote
1
answer
749
views
AngularJS - TypeError: fn is not a function [duplicate]
I want to make a function being called in a certain interval of time inside the constructor. But I don't want to write the function inside the $interval statement because it's a little big. So I ...
0
votes
2
answers
174
views
An event seems to start automatically even if it is not called [duplicate]
An event seems to start automatically even if it is not called. It should only start if something is typed.
The code automatically takes each cell and applies an event to the click that causes a box ...
0
votes
1
answer
117
views
Function as the first argument of .then() [duplicate]
Why do we have to write function() {/*call some other function*/} or () => {} inside .then() in promise?
Let's say for example that we have one promise
someFn = () => {
return new Promise((...
37
votes
3
answers
31k
views
setTimeout ignores timeout? (Fires immediately) [duplicate]
This is my first real dive into JavaScript. Sure I've used it before, but I've never really written anything from scratch.
Anyway, I'm having a very strange problem that I hope someone can figure out ...
1
vote
2
answers
1k
views
Javascript: delayed recursion with setTimeout [duplicate]
I am trying to write a recursive function which will output as audio a random sequence of letters, with a set length n, the function's only argument.
My idea was for the function to output a random ...
0
votes
1
answer
200
views
Javascript Event Queueing: XHR response in blur queued before parent onclick
For the following test case (I replaced the XHR call with setTimeout to represent an XHR call with a very fast response):
<html>
<body>
<div onclick="console.log('onclick parent'...
0
votes
1
answer
91
views
Using setInterval() function to make pomodoro timer
My code is bellow, it doesn't throw errors but it stops after running ones.
I tried reviewing this codes and searching through documentation, but couldn't find anything, possibly due to my level of ...