Variables

Variables store data temporarily in a computers memory. A common way to think of variables is to think of them like boxes. The box is used to store your things that you will use later, and you would often label the box. The box is our variable, the contents of the box is our value of that variable, and the label on the box is the name we have given the variable.

In JavaScript, as of 2024, there are two preferred ways to define your variables, these are let and const.

MDN

let

The let declaration declares re-assignable, block-scoped local variables, optionally initializing each to a value. If no value is assigned, the value would be returned as undefined.

// Declaring a variable named number with the value of 1
let number = 1;

// We could check this with a simple console.log with the
// expected output to be 1
console.log(number);