- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript history Object
JavaScript Storage & BOM
JavaScript history Object
historycontrols the browser's back and forward navigation stack.
It is the mechanism behind the browser's back and forward buttons.
Single-page applications use it to change the URL without reloading.
Example
Example
javascript
console.log(typeof history.back);
console.log(typeof history.length);The output is function then number.
The Methods
back() and forward() move one step.
go(n) moves several steps at once.
pushState adds a new entry without reloading the page.
