JavaScript

Last Updated: 12/14/2022

Constants

  • Use const when you don't want the value of the variable to be changed
  • The value of a variable as the name implies, can change, but the value of a constant cannot change
  • You cannot reassign a constant
  • The best practice is, if you don't want to reassign use const. If you want to reassign a variable use let
  • Constant declaration must be initialized
const PI = 3.14;
const inerestRate = 10;
interestRate = 20; //Error