Variables and Data Types

Variables and Data Types

let and const

  • let – reassignable.
  • const – cannot be reassigned (object/array contents can still change).
javascript
let count = 0; count = 1; const name = \"Froquiz\"; // name = \"Other\"; // error

Prefer const by default; use let when you need to reassign.

Primitives

  • number – integers and decimals.
  • string – text (double or single quotes).
  • boolean – true / false.
  • undefined – uninitialized.
  • null – intentional absence of value.
javascript
const age = 25; const greeting = \"Hello\"; const active = true;

typeof

javascript
typeof 42 // \"number\" typeof \"hello\" // \"string\" typeof true // \"boolean\"

Strings

Template literals (backticks) for interpolation:

javascript
const msg = `User ${name} is ${age} years old`;