In the section about block scope, I found it interesting that you explained it like this:
Block statements, if, for, while etc, don't create a local scope.
Is there a reason that you decided to explain it that way? Compared to explaining that var doesn't adhere to local scope and let does? I just thought it might give more clarity that it's the variables rather than the actual blocks that are concerned with scope.
I really enjoyed how you explained the this issue that people run into when learning JS. It is extremely common and the solutions you gave are spot on! I remember banging my head against the wall trying to understand it!
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 :)
In the section about block scope, I found it interesting that you explained it like this:
Is there a reason that you decided to explain it that way? Compared to explaining that
var
doesn't adhere to local scope andlet
does? I just thought it might give more clarity that it's the variables rather than the actual blocks that are concerned with scope.I really enjoyed how you explained the
this
issue that people run into when learning JS. It is extremely common and the solutions you gave are spot on! I remember banging my head against the wall trying to understand it!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.