I need to refresh the page using JavaScript. I tried both window.location.reload()
and location.reload()
. Both are working and reloading the page. Which one should I use?
Asked
Active
Viewed 2,124 times
1
-
2They are the same thing – charlietfl Jun 03 '16 at 01:17
-
1`window` is implicit. When left off, it's assumed. – StackSlave Jun 03 '16 at 01:18
-
This might help bro, [click here.](http://stackoverflow.com/questions/2405117/difference-between-window-location-href-window-location-href-and-window-location) – SMPLYJR Jun 03 '16 at 01:26
-
why not use `window.window.window.location.reload()`? it works too... – dandavis Jun 03 '16 at 01:43
-
you never need to use window, unless to skip over a local of the same name. for some reason though, a lot of code uses it extraneously but consistently; using it with `location` is common, as is `opener()`, `open()`, and `addEventListener()`... `getAppliedStyle()` seems almost always use `window.` for some reason. – dandavis Jun 03 '16 at 01:48
2 Answers
1
The Location interface represents the location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and Window.location respectively.
https://developer.mozilla.org/en-US/docs/Web/API/Location
So... they are the same thing :)

Andre Calil
- 7,652
- 34
- 41
1
Andre has the succinct answer, by far. You may also find these related questions of use from a research perspective:

Community
- 1
- 1

Mike Zavarello
- 3,514
- 4
- 29
- 43