JavaScript has 8 primitive value types:
- Undefined:A variable with no assigned value has the type undefined. For example:
let x; - Null:The type representing the absence of a value. For example:
let x = null; - Boolean:The boolean type has two values: true and false. For example:
let x = true; - String:The type used for textual data. For example:
let x = 'hello world'; - Number:The type used for representing integers and floating-point numbers. For example:
let x = 3.14; - BigInt:A type used for storing and manipulating integers of arbitrary size. For example:
let x = 9007199254740991n; - Symbol:A unique and immutable data type. For example:
let x = Symbol('hi'); - Object:The object data type is used for storing complex data structures. For example:
let x = {firstName:"John", lastName:"Doe"};
These 8 types can be broadly categorized into two types:
- Primitive values (Undefined, Null, Boolean, Number, String, Symbol, BigInt)
- Object values (Object)