Linked Questions

99 votes
8 answers
59k views

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(), ...
Adler's user avatar
  • 1,492
1 vote
3 answers
2k views

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'); ...
Sifey's user avatar
  • 29
5 votes
0 answers
21k views

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 ...
shr7's user avatar
  • 173
1 vote
1 answer
2k views

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 ...
Üsame Tekinkaya's user avatar
-1 votes
1 answer
1k views

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 ...
Andrea's user avatar
  • 164
1 vote
1 answer
749 views

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 ...
David Coelho's user avatar
0 votes
2 answers
174 views

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 ...
Andrea Fiore's user avatar
0 votes
1 answer
117 views

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((...
TeaNyan's user avatar
  • 5,089
37 votes
3 answers
31k views

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 ...
Mustard's user avatar
  • 1,830
1 vote
2 answers
1k views

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 ...
Phillip Brandel's user avatar
0 votes
1 answer
200 views

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'...
Kylos's user avatar
  • 1,948
0 votes
1 answer
91 views

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 ...
kentaa's user avatar
  • 19