clearTimeout()
can be used to cancel
a timer created using the setTimeout()
method.
The setTimeout()
method returns a number value
or its identifier value.
The clearTimeout()
method accepts only that value as argument.
In the example given above,
the timeout is cancelled before
3 seconds have passed.
Hence, the function passed to
the setTimeout()
method is never run
and
the message is not displayed.
If we remove the clearTimeout
method,
then the function runs
normally after a delay of 3 seconds.