Hello Sir/Madam,hoist}, then if both are in different scope , why it is showing error.
I have one doubt regarding this question
(function fn() {
{
let a = 10;
{
var a = 20;
console.log(a);
}
}
})();
why it is giving syntax Error ?
I know this is illegal shadowing concept but when I put braces before let a =10, then that a variable has block scoped and var a is function scoped, here after adding curly braces before let a , I have create new scope and after fn(){ // here var a is
Please help in explaining this concept.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 251 |
Nodes: | 16 (2 / 14) |
Uptime: | 100:20:48 |
Calls: | 5,516 |
Calls today: | 4 |
Files: | 11,669 |
Messages: | 5,089,169 |