Skip to main content

Data Types

JavaScript variables can hold many data types. It is a dynamically typed language, meaning typing is not strictly enforced upon initialization (unlike Java or C).

Primitive Data Types

Primitives hold a single, simple value and are immutably stored in the Call Stack.

  1. String: Text data wrapped in quotes.
    const name = "Alice";
  2. Number: Unlike other languages, JavaScript only has one Number type (no float vs int distinction).
    const age = 25;
    const price = 10.99;
  3. Boolean: True or False logic.
    const isRegistered = true;
  4. Undefined: A variable that is declared but not assigned a value.
    let futureData;
    console.log(futureData); // undefined
  5. Null: Intentional absence of any value.
    const emptyCart = null;

Reference Types (Objects)

Anything that isn't a primitive is an Object (Arrays, Functions, Objects). They are stored in the Memory Heap and referenced via a memory pointer.

Because of this reference system, if you copy an object, you are only copying the pointer address, not the actual object!