简体   繁体   中英

What is the value referred to when we assign the setTimeout function to a variable?

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.

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

The function setTimeout() returns an identifier that you can use to prevent the execution of the function by calling clearTimeout()

It is id returned from setTimeout() which used to clear the timeout

myTimeout = setTimeout(function, milliseconds);
clearTimeout(myTimeout);

For More Informtion Please Click Here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM