JavaScript Local Scope
What is Scope?
Scope determines the availability (visibility, or accessibility) of variables.
Types of Scope
There are two types of scope available in JavaScript, they are
- Global Scope
- Local Scope
Local Scope
When a variable is declared inside a function, then the variable is said to be Local.
Local variable is accessible only within the function it is declared.
Note: The following example will throw an error, Please check your console while trying it.
Example
More Examples
Local variable is also accessible to its inner function.
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.