Hi when I assign the simple setTimeOut() function to a variable and console the variable, it produces some integer value as below:
So, I want clarification on what the value denotes. The value is changing when I try the same again. So please provide me an explanation of the value we get while assigning the setTimeOut() to a variable.
CodePudding user response:
The setTimeout
function returns a unique id with which you can stop your setTimeout
like this clearTimeout(timeoutID)
.
It’s the same with setInterval
.
See here.
Greetings, Flo
CodePudding user response:
The function setTimeout() returns an identifier that you can use to prevent the execution of the function by calling clearTimeout()
CodePudding user response:
It is id returned from setTimeout() which used to clear the timeout
myTimeout = setTimeout(function, milliseconds);
clearTimeout(myTimeout);