简体   繁体   中英

How can we access variables and functions on console even if the script has been executed way before?

We know that when our whole JS program is executed it's GEC (Global Execution Context) is popped out of the call stack. And since GEC stores the global scoped variables and function, so all those memory is also released.

Then how even after executing the whole.js file, then too we are able to access those variables and function on any browser's console?

After execution of the js files, all globally scoped variables are stored on the browser's memory. you can access them by their name directly or you can access the global variable by the global object of variables named "window". like: console.log(window.varname);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM