That's a good question, and a concept a lot of people might not be familiar with, hoisting. https://www.w3schools.com/js/js_hoisting.asp   The JavaScript compiler will move all variable declarations (var) and named functions to the top of their scope.   This crazy looking code is totally valid. num = 8; num += 4; var num; console.log(num); // => 12     That's because the compiler is reading the code like this. var num; num = 8; num += 4; console.l
    • Like
    3