When you run JS in the browser, it gives you the window
object with many useful properties and methods:
window.location.href;
window.navigator.userAgent;
window.scrollTo(10, 50);
window.alert("Hello world!");
The window
object is the assumed global object on a page, so:
window.alert("Hi!");
...is the same as:
alert("Hi");