With JavaScript, the global scope is the complete JavaScript environment. In HTML, the global scope is the window object: all global variables belong to the window object. The window object is supported by all browsers. It represents the browser's window. All global JavaScript objects, functions, and variables automatically become members of the window object. Global variables are properties of the window object. Global functions are methods of the window object.
// code here can use window.carName
function myFunction() {
carName = "Volvo";
}