Documentation question

In the language overview section on variables it says:

Local variables declared using var inside a function are visible inside that function.

Are those ONLY visible inside the function? If so, you might want to chuck the ‘only’ in there to make it clear.

If “only” it were that simple.

If you declare a var outside of a function, it’s global.
If you declare a var inside of a function, it’s local.
If you declare a var outside of a function and inside a function too (same name), it’s the local version, not the global, that you’ll see in the function.

2 Likes