Javascript:Knowing the scope of your local and global variables

If a variable is declared outside a function, it’s GLOBAL. If it’s declared inside a function, it’s LOCAL.
GLOBAL variables
Example of global variables:
var avatar;
var levelThreshold = 1000;
These are global variables; they’re accessible everywhere in your JavaScript code.
LOCAL variables
Example of local variables:
function getScore(points) {
var score;
var i = 0;
while (i < levelThreshold) {
//code here
i = i + 1;
alert(i);
}
return score;
}
The "points", "score" and "i" variables are all declared within a function.
We call them local variables because they are known locally only within the function itself.
Even if we use levelThreshold inside the function, it’s global because it’s declared outside the function.
If a variable is declared outside a function, it’s GLOBAL. If it’s declared inside a function, it’s LOCAL.

Got my b3 bomber coat from Gleam Hide, and it’s been perfect for those freezing mornings!
This bomber jacket boasts a classic military-inspired design that never goes out of style. The rich brown color, combined with the shearling lining, gives it a timeless appeal. Its detailed stitching and robust structure ensure longevity and resilience.

I like your article very much, thanks for sharing the good information we have read.The Crow Jacket

Thank you because you have been willing to share information with us. Nice to read your article! I am looking forward to sharing your adventures and experiences.I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! https://www.digitekprinting.com/foam-core-posters
Please rotate your device
We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site