JavaScript Tutorial for Beginners
#15 JavaScript Tutorial | Scope of Variables | Global vs Local
Hide/Show description
Scope determines the accessibility (visibility) of variables.
In JavaScript there are two types of scope:
Local scope
Global scope
JavaScript has function scope: Each function creates a new scope. Scope determines the accessibility (visibility) of these variables. Variables defined inside a function are not accessible (visible) from outside the function.
Local JavaScript Variables
Variables declared within a JavaScript function, become LOCAL to the function. Local variables have Function scope: They can only be accessed from within the function. Since local variables are only recognized inside their functions, variables with the same name can be used in different functions. Local variables are created when a function starts, and deleted when the function is completed.
Global JavaScript Variables
A variable declared outside a function, becomes GLOBAL. A global variable has global scope: All scripts and functions on a web page can access it.
For Program code, info & more resources checkout this article - https://simplesnippets.tech/scope-of-variables-in-javascript/
Strict mode of browser - https://www.w3schools.com/js/js_strict.asp
Video by - Tanmay Sakpal
Simple Snippets Channel link - https://www.youtube.com/simplesnippets
-
#0 JavaScript Tutorial | Introduction
#1 JavaScript Tutorial | Why you should Learn JavaScript Today
#2 JavaScript Tutorial | What is Dom? | Document Object Model
#3 JavaScript Tutorial | First Hello World Program
#4 JavaScript Tutorials | Statements and comments
#5 JavaScript Tutorial | VS code Theme & Live Server Plugin Setup
#6 JavaScript Tutorial | Variables & Data Types
Support Telusko
#7 JavaScript Tutorial | Operators
#8 JavaScript Tutorial | Control Statements | Theory
#9 JavaScript Tutorial | If Else Control Statements
#10 JavaScript Tutorial | Switch case
#11 JavaScript Tutorial | For Loop
#12 JavaScript Tutorial | While loop
#13 JavaScript Tutorial | Do While loop
#14 JavaScript Tutorial | Functions
#15 JavaScript Tutorial | Scope of Variables | Global vs Local
#16 JavaScript Tutorial | Introduction to Array
#17 JavaScript Tutorial | Introduction to Objects p.1
#18 JavaScript Tutorial | Objects p.2
#19 Starting with DOM Manipulations in JavaScript
#20 Taking Input from user in JavaScript | TextBox
#21 Taking Input from Radiobuttons in Javascript
#22 Taking Input from SelectBox in Javascript
#23 getElementByTagName method in JavaScript
#24 getElementByClassName method in JavaScript
#25 Change Image onmouseover and onmouseout events in JavaScript
#26 Form Validations in JavaScript
#27 Form Validations in JavaScript part 2
#28 Regular Expressions in JavaScript Part 1
#29 Regular Expressions in JavaScript | Character Sets and Ranges
#30 Mobile Number Validation in JavaScript using Regular Expression
#31 Email Validation in JavaScript
#32 Debugging in JavaScript using Chrome Dev tools | Console Log Method
#33 Timing Functions in JavaScript
#34 Fade In Fade Out animations in JavaScript
#35 Zoom In Zoom Out effect in JavaScript
#36 Introduction to jQuery library | Setting jQuery in Project
#37 JQuery Selectors Part 1
#38 JQuery Selectors Part 2
#39 Events in JQuery Part 1
#40 Events in JQuery Part 2
#41 Effects in JQuery Part 1
#42 JQuery Animate Effect
#43 Callback and Chaining in JQuery Effects
#44 JQuery DOM Manipulations Part 1
#45 JQuery DOM Manipulations Part 2
#46 JQuery DOM Manipulations Part 3
#47 JQuery DOM Manipulations Part 4
#48 JQuery UI Including JQuery UI in Project
Date Picker Widget Control in JQuery UI
Tooltip Widget Control in JQuery UI
Accordion Widget Control in JQuery UI
Message Box Widget in JQuery UI
Autocomplete Widget in JQuery UI
Widget Modifications in JQuery UI using Getter and Setter Methods
Draggable Interaction in JQuery UI
Sortable Interaction in JQuery UI
Resizable Interaction in JQuery UI
Theming Theme Roller Customizations in JQuery UI