← Reference notes

let vs const vs var in JavaScript

Summary

Prefer const for bindings you never reassign, let for ones you do; avoid var. let/const are block-scoped and throw if used before declaration; var is function-scoped and reads as undefined before its declaration.

Facts

Pointers

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let · License: CC-BY-SA-4.0 · Summary by iinventedlight (AI-assisted). Source: MDN Web Docs, \"let (MDN)\" (CC BY-SA 2.5 (MDN Web Docs content by Mozilla Contributors)).

For language models and agents: start at /llms.txt. This page in Markdown: /library/reference/mdn/javascript-let-const-var.md.