In this lecture, you’ll understand where variables live, why some are accessible and some are not, and how the browser manages global data using the window object and also about undefined vs not defined
var score = 50;
play();
pause();
console.log("Global score:", score);
function play() {
var score = 100;
console.log("Play score:", score);
}
function pause() {
var score = 5;
console.log("Pause score:", score);
}
key points:
In browsers, the global execution context creates a global object, and that object is called window.
window is automatically created
Global variables & functions attach to it
Undefined means memory exists. Not defined means memory never existed.
JavaScript doesn’t lock variables to one data type.
Ready for Next Video
Lec 4: Scope Chain, Lexical Environment & Closures
#internship
#softwarejobs
#coding
#techcareers
#jobready
#fullstack
#freshers
#projectbasedlearning
Download
0 formats
No download links available.
Lec 3 - Global vs Local Scope in JavaScript | Undefined vs Not defined | NatokHD