Zmienna blokowa JavaScript 9
// program showing block-scoped concept
// global variable
let a = 'Hello';
function greet() {
// local variable
let b = 'World';
console.log(a + ' ' + b);
if (b == 'World') {
// block-scoped variable
let c = 'hello';
console.log(a + ' ' + b + ' ' + c);
}
// variable c cannot be accessed here
console.log(a + ' ' + b + ' ' + c);
}
greet();
SAMER SAEID