Jeff
Jeff

Reputation: 245

Is window.location.reload() or location.reload() better?

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?

Upvotes: 1

Views: 3247

Answers (2)

Mike Zavarello
Mike Zavarello

Reputation: 3554

Andre has the succinct answer, by far. You may also find these related questions of use from a research perspective:

Upvotes: 1

Andre Calil
Andre Calil

Reputation: 7692

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 :)

Upvotes: 1

Related Questions