Skip to content
Kodi Wizards
Home / Videos / Programming Basics #23 Variable Scope
Videos

Programming Basics #23 Variable Scope

March 28, 20141 min readBy Kodiw

http://learn-share.net/programming-basics-course/
Programming Course. The Basics of Programming.
#23 Variable Scope

Learn to code.

Understanding variable scope

One more thing you should be aware when working with functions. And not only for javascript but for most modern programming languages.

When you create a function, and define a variable inside that function using the word var, this variable is only available inside this same function.

And this is because of something called, variable scope. Any variable have a scope. And this means, where this variable is visible. Who can see it, who can use it.

So, we defined this simple function, and then we call it.

What going to happen is, we jump in to the function, will create the variable, and pop up the alert box with the contents of that variable which is 500.