Variables
- var → globally scoped, not used much anymore
- let → allows value reassignment
- const → constants which cannot be re-assigned
// Note that variables only need let/const the _first_ time they are declared, not during reassignment
let age = 30;
age = 31; // This is allowed, overrides the value of age
// Also note that because age has been declared with let, it cannot be re-declared
const age =30;
age = 31; // This will fail
let name = "Adnan"
let/const name = "anything" // this will fail
Because we cannot re-declare a variable, it is common to simply initialize variables, like so (only with let):
let score;
let currentTime;
// Both of these return "undefined"
const score; // This will lead to an initialization error