Javascript Function Global Object In Browser
<html> <!-- Demonstrating the nature of the global and window objects --> <head></head> <body> <script> let mylet = "Hello"; function checkVars1() {//from w w w . j a v a 2 s. c o m console.log("checkVars1: Checking myVar: " + mylet); // "Hello" } function checkVars2() { let mylet = "World"; console.log("checkVars2: Checking myVar: " + mylet); // "World" console.log("checkVars2: Checking window.myVar: " + window.mylet); // "Hello" } checkVars1(); checkVars2(); </script> </body> </html>