None of the code you've supplied relates to a "dictionary".
var
vs. let
determines the scope that the variable has. With var
, the variable is scoped to its containing function (or the Global scope, if outside of all functions).
let
gives the variable block level scope which can be more granular than function level scope (i.e. branches of an if
/else
statement).
If the declaration is in the Global scope, then let
vs. var
won't make any difference because the scope is Global.
Both declarations will create global variables, but let
doesn't explicitly create a named property on the window
object as will happen with var
.
See this for details.
Also from MDN:
let
allows you to declare variables that are limited in scope to the
block, statement, or expression on which it is used. This is unlike
the var
keyword, which defines a variable globally, or locally to an
entire function regardless of block scope.
And, from the ECMAScript spec. itself:
let
and const
declarations define variables that are scoped to the
running execution context’s LexicalEnvironment.
A var
statement declares variables that are scoped to the running
execution context’s VariableEnvironment.
This is why globally declared let
variables are not accessible via window
like globally declared var
variables are.