I am confused as to the difference between window.location and location.href. Both appear to be acting in the same way.
What is the differe
They are different. window.location is an object containing the property href which is a string.
Setting window.location and window.location.href behave the same way, as you noticed, because it was built into the JavaScript language long ago. Read more in this question about setting window.location.
Getting window.location and window.location.href behave differently because the former is an object and the latter is a string. If you run string functions like indexOf() or toLowerCase(), you have to use window.location.href.