See the title. When calling fetch in our react project, a (now departed) developer originally used from fetch to window.fetch. I'm not sure of the difference and can't find anything conclusive online (W3Schools doesn't even mention fetch as a function of the window)
1 Answer
On your developer console, try this experiment:
fetch === window.fetch
You'll see that this returns true
. They are in fact the same thing.
window
is the global object in a browser context. The browser APIs (distinct from language features) are found on the global window
object.
-
2"Much of the framework you're using is built on the window object." --- this is a weird one.– zerkmsSep 12, 2019 at 4:44
-
1
-
1"All browser APIs are provided through the
window
global object." ? Sep 12, 2019 at 5:25
window.fetch
in most cases as the global scope iswindow
. There is no difference.fetch === window.fetch
. Same thing.