9

Does the setTimeout function clear/destroy itself when done, or do I need to manually call clearTimeout within the callback?

0

2 Answers 2

11

It clears itself.

You only have to call clearTimeout if you want to cancel it before it fires.

Sign up to request clarification or add additional context in comments.

Comments

8

Yes it clears itself automatically when the timeout finishes and the function is fired.

The manual clearing is used to stop the countdown from finishing and the callback from firing. It has no function in the callback since the timeout is already cleared.

1 Comment

You dont have to do cleartimeout, It is used to stop timer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.