← All tutorials

GoCareerGo Tutorials

JavaScript Tutorial

Variables to closures, promises, the DOM and OOP — a complete JS reference.

JavaScript Data Types

JS has 7 primitive types plus Object, and uses dynamic typing — a variable's type can change at runtime.

  • Primitives: Number, String, Boolean, Undefined, Null, Symbol, BigInt
  • Non-primitive: Object (includes Array, Function, Date, Map, Set...)
  • typeof returns a string describing the type
  • Primitives are copied by value; objects are copied by reference
typeof 42;          // 'number'
typeof 'hi';         // 'string'
typeof true;          // 'boolean'
typeof undefined;     // 'undefined'
typeof null;          // 'object' (a famous JS quirk)
typeof Symbol();       // 'symbol'
typeof {};             // 'object'
typeof [];             // 'object'
typeof function(){};   // 'function'
Tip

typeof null returning 'object' is a classic gotcha question — know it's a long-standing bug kept for backward compatibility.