What are the key differences between var, let, and const in JavaScript? When would you use each one?
JavaScript

var vs let vs const
varis function scoped and if you try to use a variable declared withvarbefore the actual declaration, you'll just getundefined.constandletare blocked scoped and if you try to use variable declared withletorconstbefore the declaration you'll get aReferenceError.- Finally the difference between
letandconstis that once you've assigned a value toconst, you can't reassign it, but withlet, you can.
var vs let vs const
var:
function scoped
undefined when accessing a variable before it's declared
let:
block scoped
ReferenceError when accessing a variable before it's declared
const:
block scoped
ReferenceError when accessing a variable before it's declared
can't be reassigned00:00