Home/Tutorials/JavaScript/Variables: let and const

0 of 3 saved

JavaScript5 min read

Variables: let and const

Read this chapter, write the program on this page, then pass a short check to open the next one.

Modern variable declarations.

Variables: let and const

Prefer const when the binding will not change. Use let when you need to reassign. Avoid var in new code.

  • const locks the binding (not deep object contents).
  • let is block-scoped.
  • Always declare before use.
const site = "StudyTonight";
let visits = 0;
visits += 1;
console.log(site, visits);

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.