The replace() method is used for replacing the current document with a new one. It is similar to the assign() method but the main difference is that replace() method removes the current URL from the history list and we can not go back or navigate backward.
Its syntax is:- location.replace(URL)
|URL||Required. The URL of a page to navigate to.|