Comprehensive guide to JavaScript fundamentals
// Variables and Constants in JavaScript
const accountId = 123312; // always use const as a constant
let accountEmail = "kachua@gmail.com"; // always use let as a variable
var accountcity = "banglore"; // do not use var as it has scope problems
accountname = "kachua"; // bad way to declare variables
// Key Points:
// • const - cannot be reassigned, use for constants
// • let - block-scoped, preferred for variables
// • var - function-scoped, avoid using (scope issues)
// • Never declare without keyword (creates global variable)
console.table([accountId, accountEmail, accountcity, accountname]);
const
for values that won't changelet
for variables that will changevar
due to scope issues