The JavaScript History object contains the browser’s history. First of all, the window part can be removed from window.history just using the history object alone works fine. The JS history object contains an array of URLs visited by the user. By using the history object, you can load previous, forward, or any particular page using various methods.
JavaScript history object Properties:
length: It returns the length of the history URLs visited by the user in that session.
JavaScript history object Methods:
forward(): It loads the next page. Provides the same effect as clicking back in the browser.
back(): It loads the previous page. Provides the same effect as clicking forward in the browser.
go(): It loads the given page number in the browser. history.go(distance) function provides the same effect as pressing the back or forward button in your browser and specifying the page exactly that you want to load.