if i assign let
some other value, how interpreter still understand its original use.
For further actions, you may consider blocking this person and/or reporting abuse
For further actions, you may consider blocking this person and/or reporting abuse
Hossein Yazdi -
Shalwin Sanju -
Sushant Gaurav -
Mads Stoumann -
Top comments (2)
Top result from googling "var javascript block scope":
Your
let b = ...
is within theif (...) { ... }
block and is destroyed when leaving the block. Thevar a = ...
will live outside the block.As for the
let = ...
,async = ...
andawait = ...
assignments, all three of those are being assigned as variables because or your beginningvar ...
syntax. It wouldn't be good to make variables with these names anyway and your console highlighting them is evidence of this bad practice (IMHO you should be prevented from creating those variables as those names should be reserved, but that could break compatibility between versions.)The best practice is to pick either
var
orlet, const
. Mixingvar, let and const
together can lead to unexpected behavior.var
is function scoped,let, const
are block scoped.