JS Data Types

Primitive vs Reference Types

  • Primitive: string, number, boolean, null, undefined, symbol
  • Reference: object (arrays, functions, objects)

Type Checking

Use typeof for primitives and instanceof for objects.

Examples

typeof 'hello'    // 'string'
typeof 123        // 'number'
typeof null       // 'object'
[1,2,3] instanceof Array // true