The present reference page for var
declarations says, under ‘Description’:
Variable declarations, wherever they occur, are processed before any code is executed.
The problem is that for newer JavaScript programmers (e.g. me), it’s not clear if this statement includes let
and const
declarations. A “variable declaration” could specifically mean a var
declaration, but at the same time, let
makes variables too, so a “variable declaration” could include let
declarations.
I’d like to clear this up on the var
page as well as in any other place I can find where it might be ambiguous, but first I need to know which is true:
- Are only
var
declarations, wherever they occur, processed before any code is executed, or - Are
var
,let
, andconst
declarations, wherever they occur, processed before any code is executed.
Or any mixture thereof.
Thanks!