| 232 | */ |
| 233 | |
| 234 | function testingConst() { |
| 235 | // * hoisting const |
| 236 | // ! error |
| 237 | // console.log(test);// ReferenceError: test is not defined |
| 238 | const test = 1; |
| 239 | |
| 240 | // * const cannot be reassigned |
| 241 | // test = 2; |
| 242 | // console.log(test);// Cannot reassign a variable declared with const |
| 243 | |
| 244 | // * const cannot be re declared |
| 245 | // const test = 3; // Cannot re declare a variable declared with const |
| 246 | |
| 247 | // ! const is block scope |
| 248 | // ! we cannot access inner block from outer |
| 249 | if (true) { |
| 250 | const access = false; |
| 251 | } |
| 252 | |
| 253 | // * const is block scopes |
| 254 | // console.log(access);// ReferenceError: access is not defined |
| 255 | } |
| 256 | |
| 257 | testingConst(); |
| 258 | |