The following one type can be considered as canonical to navigate to a new URL is following.
window.location = 'https://appdividend.com';
If you want to redirect to a different path, on the same domain, use:
window.location.pathname = '/yournewpath';
If you have used any frontend frameworks like Angular, React, or Vue then you might be familiar with history API. In this structure of a History API, the hash(#) is not there.
#Other Options To Redirect
In this browser, we can access the global object called a window. So you can do the following.
location = 'https://appdividend.com';
There is also another way is to set the href property of location.
window.location.href = 'https://appdividend.com';
The location() also has an assign() method that accepts a URL and performs the same thing.
The browser exposes the self and top objects, which all reference the window object, so you can use them instead of the window in all the examples above.
self.location = 'https://appdividend.com'; top.location = 'https://appdividend.com';
#Location replace() Method
The replace() method replaces the current document with a new one document.
The significant difference between this method and assign(), is that the replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document. It completely replaces it.