Example in Action: Function Scope

Scope in JavaScript can be broken into two types: local and global. When you declare a variable inside a function, a function will have its local scope. A global variable will be declared outside of functions and can be used throughout the code segments. When using global variables, you must be careful because there are rules for when your global and local variables have the same name and how the precedence will work.  Watch this video for how scope is implemented in JavaScript.


Source: Coding from zero, https://www.youtube.com/watch?v=6A2RfkpvphI
Creative Commons License This work is licensed under a Creative Commons Attribution 3.0 License.

Last modified: Monday, August 21, 2023, 11:43 PM