JS clearInterval or window.clearInterval?

clearinterval, javascript, setinterval

Solution

In a browser, all global functions are implicitly properties of the `window` object. So `clearInterval()` and `window.clearInterval()` are the exact same thing.

There is no difference between them unless you define a local function called `clearInterval()`, in which case `window.clearInterval()` would reference the global one and `clearInterval()` would reference the local one.

The same would be true for any global functions that you define yourself.

Problem

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.

Original source