filmov
tv
Basic Javascript (50/111) | Local Scope and Functions | freeCodeCamp
![preview_player](https://i.ytimg.com/vi/NHbbAmXFjXQ/sddefault.jpg)
Показать описание
Basic Javascript (50/111) | Local Scope and Functions | freeCodeCamp
"Variables which are declared within a function, as well as the function parameters have local scope. That means, they are only visible within that function.
Here is a function myTest with a local variable called loc.
function myTest() {
var loc = ""foo"";
}
myTest(); // logs ""foo""
loc is not defined outside of the function.
Note: The console will still have 'ReferenceError: myVar is not defined', but this will not cause the tests to fail."
"Variables which are declared within a function, as well as the function parameters have local scope. That means, they are only visible within that function.
Here is a function myTest with a local variable called loc.
function myTest() {
var loc = ""foo"";
}
myTest(); // logs ""foo""
loc is not defined outside of the function.
Note: The console will still have 'ReferenceError: myVar is not defined', but this will not cause the tests to fail."