A Variable
Variables are used to store data (for example age, number, store items, person, etc...). We can declare variables in JavaScript with let, const, and var.
Let
Let is used to store a value that needs to change in our code. Example age
let age = 30;
//On my birthday
age = 31;
console.log(age); //expected value 31
Const
Const is used to store values that don't need to change(immutable variables). Example birthyear
const birthyear = 1992;
//if we try to reassign birthyear we get an error
birthyear = 2000;
console.log(birthyear); //expected value error
Var
Var is just like let meaning you can assign and reassign the value but is an old-school way of using Let.
var message = "Hello";
Top comments (0)