How to Use JavaScript variables?

JavaScript provides two different ways of explicitly defining new variables and one way of defining constants.

  1. const: For constant block scoped values that cannot be changed later on.
  2. let: For block scoped variables where we want to be able to change the value.
  3. var: For global/function scoped variables that can be changed and redeclared. (should not be used in modern JavaScript code)