Javascript has setInterval and clearInterval functions for handling asynchronous function calls.
Is there a difference between clearInterval(handle)
and window.clearInterval(handle)
?
I've seen it being used both ways.
Javascript has setInterval and clearInterval functions for handling asynchronous function calls.
Is there a difference between clearInterval(handle)
and window.clearInterval(handle)
?
I've seen it being used both ways.
In a browser, all global functions are implicitly properties of the
window
object. SoclearInterval()
andwindow.clearInterval()
are the exact same thing.There is no difference between them unless you define a local function called
clearInterval()
, in which casewindow.clearInterval()
would reference the global one andclearInterval()
would reference the local one.The same would be true for any global functions that you define yourself.
window
is the global context object. If you are not in a function that has had it's scope modified, everything you type is implicitly preceded bywindow.
.There is no real difference
This is basically the same as the following where global variable are a properties of the window object.
or where global functions are properties of the window object.