Categories
Genesis

Data Structure: The History API

Every array in JavaScript has push and pop methods. Because even arrays are objects in JavaScript.

The History API was built around this data structure.

window.history.pushState pushes data into an array in the history object.

window.onpopstate is an event handler in the window object, receiving the popped value from the popped method in the history object.

Arrays are quite powerful when you bring your imaginations to life!