Junior — Middle
Can you list the main data types used in JavaScript?
sobes.tech AI
Answer from AI
In JavaScript, the following main data types exist:
-
Primitive types:
Number— numeric values (integers and floating-point)String— stringsBoolean— logical values (trueorfalse)Undefined— the value of a variable that has not been assigned a valueNull— a special value indicating the absence of a valueSymbol— unique and immutable identifiersBigInt— integers of arbitrary length
-
Objects:
Object— a collection of key-value pairs- Arrays, functions, dates, and other data structures are objects
Example:
let num = 42; // Number
let str = "Hello"; // String
let flag = true; // Boolean
let nothing; // Undefined
let empty = null; // Null
let sym = Symbol('id'); // Symbol
let big = 9007199254740991n; // BigInt
let obj = {name: "Alice"}; // Object