What is the difference between history.pushState() and history.replaceState()?
The key difference is how they modify history: 1) pushState() adds a new entry to the browser's history stack, increasing its length, 2) replaceState() modifies the current history entry in place without adding to the stack, 3) Both methods accept the same parameters: state object, title, and URL, 4) Both methods change the URL without triggering a page reload, 5) pushState() enables the back button to return to the previous state, 6) replaceState() overwrites the current history entry, so the back button skips over it, 7) pushState() is commonly used when creating new navigation states the user might want to return to, 8) replaceState() is typically used for updating the current state without creating navigation history, such as when updating query parameters or hash fragments that don't represent distinct application states.