function test(){
var x = "Available inside this function";
console.log(x);
}
test(); // this will output: "Available inside this function"
console.log(x); // will output: ReferenceError: x is not defined
It works the same for functions.
function test(){
var x = "Available inside this function";
console.log(x);
}
test(); // this will output: "Available inside this function"
console.log(x); // will output: ReferenceError: x is not defined
It works the same for functions.