theory.js

Variables & Data Types

Declaring Variables

JavaScript allows variable declarations using var, let, and const, each with different behaviors.

  • var: Function-scoped, hoisted, can be redeclared.
  • let: Block-scoped, hoisted but uninitialised, cannot be redeclared.
  • const: Block-scoped, must be initialised, cannot be reassigned.
var name = "Jake";
let age = 25;
const country = "Australia";