Interview Question

What are data types in JavaScript?

JavaScript has seven primitive types plus the Object type.

💡 Concept ✅ Quick Revision ⚡ JavaScript

Answer

JavaScript values are either primitive values or objects. • Primitive types are Undefined, Null, Boolean, String, Symbol, Number, and BigInt. • Object values include ordinary objects, arrays, and functions. • typeof reports a string describing the operand, with historical special cases.

Example

Code
console.log(typeof 42);
console.log(typeof 42n);
console.log(typeof 'hi');
Output
number
bigint
string

Quick Revision

JavaScript has seven primitive types plus the Object type.