Linked Questions

3263 votes
45 answers
490k views

var funcs = []; // let's create 3 functions for (var i = 0; i < 3; i++) { // and store them in funcs funcs[i] = function() { // each should log its value. console.log("My value:", i); ...
nickf's user avatar
  • 548k
8 votes
2 answers
2k views

Let me clarify my question. I'm not asking how to make the following code work. I am aware that you can use the let keyword or an iffe that captures its own value of i. I just need clarification on ...
-1 votes
2 answers
5k views

I want to iterate an array in Javascript and one element will take some time to get processed. I want to till that element is processed, wait for that. var splittedText = ["Hello", "World", "How", ...
-1 votes
1 answer
1k views

I'm trying to step through an array and pass my urls stored there to the window.open function. This is what I have. $('a.linked').click(function(e) { e.preventDefault(); var i; var urls = ...
0 votes
0 answers
606 views

I have a node websocket (require('ws')) server that i want to test in terms of load (active connections). Hence I am trying to write a node client app that makes several connections to the server and ...
-1 votes
2 answers
291 views

For loop in node.js is behaving quite weirdly. code is as below: for(var i = 0; i < req.body.stages.length; i++){ if (req.body.current_stage == req.body.stages[i].stage_short_desc){ ...
0 votes
2 answers
151 views

Please find my snippet here, for (var i=0;i<11;i++) { setTimeout( () => console.log(i), 10); } How it print 11 for 11 times? since i was set < 11? if i console it without ...
0 votes
0 answers
184 views

I have created a websocket server using ratchet, and would like to monitor my servers CPU/Ram usage as the number of concurrent connections goes up. I've tried to do this in the dev console with a ...
0 votes
1 answer
100 views

I am using a loop to update data to the server and once the response from the server is received it is updated in my local db.But before completing all the updates in local db the promise gets ...
0 votes
0 answers
79 views

I have a table in a database which has a list of bad_wordsand a list of good_words which replace these bad_words in the input string. This is how I'm doing it, the parameter comment is to be tested ...
sbrk's user avatar
  • 1,520
-2 votes
1 answer
76 views

in a loop - get some data from mysql insert the data into specific array ( at the index of i) but as you know, 'i' increases much earlier than I expected. I know it's a problem with a sync/async ...
MJK's user avatar
  • 15
0 votes
0 answers
69 views

I'm converting a PHP code to NodeJS. I was running a couple MySQL queries, then I would run other ones based on these results. However, it seems like MySQL queries are run in a particular order in ...
user1319182's user avatar
0 votes
0 answers
78 views

I am trying to learn javascript basics through an online course. I have a set of functions that work and I want to run them through a for loop 10 times. Here is the code of my for loop: for (var ...
0 votes
0 answers
62 views

I'm trying to create a JavaScript object (friends_ringsigs), in which the keys are the values of names[i], and the values are the "result" variable created at the execution of the promise. The problem ...
0 votes
0 answers
58 views

Here is the code i am facing problem for (var j = 0; j < 3; j++) { console.log("for loop"+j); Data.getById(item) .then(function (data) { ...

15 30 50 per page
1
2 3 4 5
...
9