What is the purpose of push() and replace() methods of history in ReactJS?

In ReactJS, a history instance has two methods for navigation purpose.

  • push() method
  • replace() method
    If we think of the history as an array of visited locations, then the push() method will add a new location to the array and the replace() method will replace the current location in the array with the new one.