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.
3 Comments
zerkms
"Much of the framework you're using is built on the window object." --- this is a weird one.
Brad
@zerkms Feel free to re-word if you have a better way to describe it.
Jonas Wilms
"All browser APIs are provided through the
window global object." ?
window.fetchin most cases as the global scope iswindow. There is no difference.fetch === window.fetch. Same thing.