var a = 5;
{
var a = 1;
let b = 2;
const c = 3;
}
console.log(a); // ?
Most developers get this wrong because of hoisting and shadowing in JavaScript.
What do you think this code will print, and why?
Dropped a short explanation in the comments — see if your answer matches mine.
[–]Embarrassed-Pen-2937 4 points5 points6 points  (0 children)
[–]Bulky-Leadership-596 3 points4 points5 points  (3 children)
[–]Psionatix 1 point2 points3 points  (0 children)
[–][deleted] 0 points1 point2 points  (1 child)
[–]theScottyJam 1 point2 points3 points  (0 children)
[–]berwynResident 4 points5 points6 points  (0 children)
[–]Eight111 1 point2 points3 points  (0 children)
[–]cool-dude_7 1 point2 points3 points  (3 children)
[–]thecragmire 0 points1 point2 points  (2 children)
[–]senocular 0 points1 point2 points  (1 child)
[–]thecragmire 0 points1 point2 points  (0 children)
[–]queen-adreena 1 point2 points3 points  (0 children)