Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Scope of variables and constants

  • let
  • var
  • const

There are several ways to start declaring and using variables and constants. In general the best is to use the let keyword.

x = "Joe"
var y = "Jane"
let z = "George"
const w = "nothing"

console.log(x) // Joe
console.log(y) // Jane
console.log(z) // George
console.log(w) // nothing