@mbtamuli
x = 42;
console.log(y);| Scope | |
|---|---|
| var | Function |
| let | Block |
| const | Block |
function exampleFunction() {
// x can only be used in exampleFunction
var x = "declared inside function";
console.log("Inside function");
console.log(x);
}
console.log(x); // Causes errorlet person = "Mriyam"
function otherFunction() {
person = "Tony";
{
let innerPerson = "Mary";
console.log(innerPerson);
}
}
otherFunction();
console.log(person); // ??
console.log(innerPerson); // ??// Tony