What is a function scope?
Function Scope: When a variable is declared inside a function, it is only accessible within that function and cannot be used outside that function. Block Scope: A variable when declared inside the if or switch conditions or inside for or while loops, are accessible within that particular condition or loop.What are the scopes available in JavaScript?
There are three types of scope in JavaScript — 1) Global Scope, 2) Function Scope, and, 3) Block Scope.
- Global Scope. Any variable that's not inside any function or block (a pair of curly braces), is inside the global scope. ...
- Local Scope or Function Scope. ...
- Block Scope.