I played with some code and came across a situation where I could not determine why the “let” behaves the way it does.
For the bottom block of code:
I get the error "x not defined" when I execute f (). I understand that the "let" variables were not raised, but since "x" has a global copy, why not the line inside the "f" function by default for the global copy, and not to throw an error? "Allows" to set the variable to uneclared (instead of "undefined" with var due to the rise) at the beginning of the function? Is there a way to get a global copy of "x" inside a function?
source share