hey Will.. I've seen many articles referring it as if, for, while, doesn't create a new scope but function does, here for example scotch.io/tutorials/understanding-.... I mean I totally see your way as well, especially with MDN saying this about let, let allows you to declare variables that are limited to the scope of a block statement. Yea I'll see if I can amend this in a good way, appreciate the comment :)
hey Will.. I've seen many articles referring it as
if
,for
,while
, doesn't create a new scope but function does, here for example scotch.io/tutorials/understanding-.... I mean I totally see your way as well, especially with MDN saying this aboutlet
,let allows you to declare variables that are limited to the scope of a block statement
. Yea I'll see if I can amend this in a good way, appreciate the comment :)You should probably also mention that
gets you
1 2 3
, whereaswill output
4 4 4
. IMO this is one of the major reason why scope of loop variable matters.