Linked Questions

4 votes
2 answers
216 views

I want to print a string of my choice to the console after 2 seconds. This prints 'Hello' to the console after 2 seconds: function log() { console.log("Hello") } t = setTimeout(log, 2000) But I ...
3 votes
3 answers
406 views

I needed to pass a parameter to a callback function in Javascript, so I did the following which creates an anonymous function as a string and then passes it: var f = "var r = function(result) {...
new299's user avatar
  • 814
-2 votes
1 answer
137 views

I would like to pass some parameter in call back like the following example. Is it a possible? Or I need to do it in another way? function testCallback(callback, destination){ // how can I pass ...
travistam's user avatar
0 votes
1 answer
73 views

I tried this but it's immediately invokes addClass after opening website : function onMouseOver(element, event) { element.addEventListener("mouseover", () => { event }) } onMouseOver(...
Marcin's user avatar
  • 3
0 votes
1 answer
59 views

let testTime = document.querySelectorAll(".testTime"); // this List has 3 value. 30, 60, 120 testTime.forEach((x) => { console.log(x.innerHTML); addEventListener("click",...
0 votes
0 answers
30 views

I have this structure function foo() { var obj = []; var text = '...'; text = text.replace(/.../g,matching_fn); } function matching_fn($match, $match1, $match2) { // i need obj here } ...
rhavin's user avatar
  • 1,804
0 votes
0 answers
20 views

I'm working with a JavaScript library, and it takes callbacks as a parameter to functions, that execute when the function is completed. So, for instance, I have something like: bot.dig(target, ...
56 votes
5 answers
47k views

I have a function callWithMagic which takes a callback function as a parameter and calls it with one argument. const callWithMagic = callback => { const magic = getMagic(); callback(magic); }; ...
11 votes
4 answers
18k views

I need to watch a small number of directories in a Node.JS application: function updated(event, filename){ log("CHANGED\t/share/channels/" + filename); } for(i in channels) fs.watch('share/...
19 votes
2 answers
54k views

I know this is a duplicated question with ES5, but I am looking for the syntax with ES6 arrow function. My code below: fetchItems = (callback) => { //After ajax success callback(response); ...
9 votes
2 answers
11k views

I'm stumped on how to correctly pass parameters to a callback function without immediately calling that function. For example, this will work as expected: var callBack = function() { ... } window....
5 votes
5 answers
5k views

I'm building a system in Node.js that is supposed to find all files in an array of folders, stat them, and then do some additional work using that information. I'm using fs.readdir() to get all the ...
0 votes
4 answers
3k views

I had started to learn JavaScript for web development and I am currently stuck at a point in the callback function. The problem is that I can't understand how arguments are passed in JavaScript. CODE: ...
2 votes
4 answers
4k views

I have this simple code : console.log('calling doWork func...') doWork('a', 'b', myCb); function doWork(param1, param2, callback) { console.log('in func') callback(); } function ...
Royi Namir's user avatar
  • 149k
-1 votes
2 answers
2k views

I need to make a div that covers my entire screen be displayed before an sync ajax call. But it seems that absolutely nothing I try to do causes the DOM to be modified to show this div before the ...

15 30 50 per page
1
2 3