Global Scope
Variables declared outside any function or block belong to the global scope. They can be accessed from anywhere in the code.
<script>var globalVar = "I am global";
console.log(globalVar); // Accessible here
function test() {
console.log(globalVar); // Accessible inside the function
}
test();
Leave a Reply