Data Types
EasyIn plain terms
JavaScript has 8 data types: string, number, bigint, boolean, undefined, null, symbol, and object. Use typeof to check types. Primitives are immutable; objects are passed by reference.
What you need to know
- •Primitives: string, number, boolean, undefined, null, symbol, bigint
- •Object: arrays, functions, plain objects
- •typeof operator for type checking
Try it yourself
Copy the code below and run it in your browser console or a code editor:
typeof 'hello'; // "string"
typeof 42; // "number"
typeof true; // "boolean"
typeof undefined; // "undefined"
typeof null; // "object" (historical bug)
typeof {}; // "object"
typeof []; // "object"
typeof Symbol(); // "symbol"
typeof 10n; // "bigint"Learn more
Dive deeper with these trusted resources: