Answer the question
In order to leave comments, you need to log in
Why does setTimeout() fire without a second argument?
There is this code:
setTimeout(() => {
console.log('hello');
});
Answer the question
In order to leave comments, you need to log in
"Some digit" is the timeout identifier that the function returns, can be later used to pass to the clearTimeout function (cancels the timeout).
And the second argument is the delay in milliseconds, if not set, then 0 is used, but in reality this does not mean that the function will be instantly executed, it may take 16 ms or even more (depending on the load of the browser).
I have everything working right now.
setTimeout() as well as setInterval() return a numeric ID of the counter so that it can be canceled via clearTimeout(timeoutId)/clearInterval(intervalId)
because
var timeoutID = scope.setTimeout(function[, delay, param1, param2, ...]);
delay - Optional
The time, in milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. If this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, as soon as possible. Note that in either case, the actual delay may be longer than intended; see Reasons for delays longer than specified below.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question