()
| 192 | */ |
| 193 | |
| 194 | function testingLet() { |
| 195 | // * hoisting let |
| 196 | // ! error |
| 197 | // console.log(test);// ReferenceError: test is not defined |
| 198 | let test = 1; |
| 199 | |
| 200 | // * let can be reassigned |
| 201 | test = 2; |
| 202 | console.log(test); // 2 |
| 203 | |
| 204 | // * let cannot be re declared |
| 205 | // let test = 3; // ERROR |
| 206 | |
| 207 | // ! let is block scope |
| 208 | // ! we cannot access inner block from outer |
| 209 | if (true) { |
| 210 | let access = false; |
| 211 | } |
| 212 | |
| 213 | // * let is block scopes |
| 214 | // console.log(access);// ReferenceError: access is not defined |
| 215 | } |
| 216 | |
| 217 | testingLet(); |
| 218 |