Scope Introduction
Introduction to scopes.
We'll cover the following
Background
Have you ever wondered: who can access a variable that you declare? Imagine assigning a variable to a password or encryption key; if either is compromised, your whole system is compromised. In this scenario, you are likely to restrict access to the variables. You can keep these variables where they can’t be accessed. In fact, you can even reuse variable names in multiple scenarios without worrying about duplicate names and overwriting its value.
In the programming world, this restriction of access, or creating boundaries within which a variable is accessible, is done through the scope of the variable.
Introduction
The scope is the extent to which a variable is accessible throughout the program at run-time. In other words, scope partitions the visibility of variables and resources throughout the program.
Get hands-on with 1400+ tech skills courses.