What is the difference between window.location.assign()
and window.location.replace()
, when both redirect to a new page?
location.assign():
To assign route path by passing path into it. Assign will give you a history even after path was assigned.
Usage Method: Value should be passed into it.
Eg: location.assign("http://google.com")
location.replace():
It helps to replace path if you don't want to keep history. It won't give you a history once you replace its path.
Usage Method: Value should be passed into it.
Eg: location.replace("http://google.com")