Zerium
Zerium

Reputation: 17333

What happens when clearTimeout is called on a variable with setTimeout on it?

So, what I mainly was wondering, was if clearTimeout(t); is the same as t = undefined.

Upvotes: 0

Views: 216

Answers (2)

Bill
Bill

Reputation: 25555

It's pretty easy to test out for yourself. Here's a fiddle where you can see that Axel is correct: http://jsfiddle.net/s3sUU/.

Upvotes: 2

Áxel Costas Pena
Áxel Costas Pena

Reputation: 6235

No, the value returned by setTimeout is just a number, a primitive type, and it's just used like an "index" or "identifier" when used in clearTimeout. But it's not a pointer to the function.

Upvotes: 2

Related Questions