JavaScript · Language basics

let / const

Block-scoped declarations. Use const by default and let only when reassigning. Neither is hoisted to a usable value.

Syntax
let count = 0; const name = "Ada";

Example

Try it

Notes

Prefer const for values that never rebind. Avoid var in new code.

More in this group

Arrow function Chained comparison Comma operator Default parameter destructuring for…in for…of Function declaration

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course