All modern browsers support JavaScript’s “Strict Mode.”
You will learn more about how to use Strict Mode in a later chapter of this tutorial.
In “Strict Mode,” undeclared variables are not automatically treated as global. |
In JavaScript, the global scope refers to the JavaScript environment.
In HTML, the global scope is represented by the window object.Global variables declared with the var keyword become properties of the window object.
var carName = “Volvo”; // code here can use window.carName |
Global variables declared with the let
keyword do not become properties of the window
object.
let carName = “Volvo”; // code here can not use window.carName |