{}
is overloaded to be either an object literal or a block scope. When an assignment is made to a variable inside of the {}
, it then becomes a block scope. Otherwise it is treated as an object literal.
var
, let
, and const
respect block and function scopes differently. var
is also hoisted and can be redeclare while that is not true for let
and const
. This lesson goes more in depth on scope and how each variable declaration treats it differently.
What extension do you use to show the console.log value at the end of the code line?
I use the pro version of this: https://quokkajs.com/docs/index.html