JavaScript

Const vs Let vs Var

Definition

`const` declares a block-scoped, read-only reference (the value itself can still be mutated for objects/arrays). `let` declares a block-scoped, reassignable variable. `var` declares a function-scoped, hoisted variable. Prefer `const` by default, `let` when reassignment is needed, avoid `var`.

Code Example

Javascript
Tip: Modify the code above and click “Run” to see the results

Learn More

Related Terms