← BYTES
JavaScript·Starter·Ref: 3.1.4

What is the main difference between variables declared with `let` and `var`?

Have a question about this video? Mention reference 3.1.4 when you contact us.

a.There is no difference
b.`var` can only hold numbers
c.`let` is block-scoped; `var` is function-scoped (and hoisted with an initial value of undefined)
d.`let` variables cannot be reassigned
`var` declarations are scoped to the nearest enclosing function (or global scope) and are hoisted with an initial undefined value; `let` (and `const`) are scoped to the nearest enclosing block, and accessing them before their declaration throws a ReferenceError instead of silently returning undefined (the 'temporal dead zone').

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES314#JavaScript