Middle
What data types do you know in JavaScript?
sobes.tech AI
Answer from AI
JavaScript has the following main data types:
-
Primitive types:
Number— numeric values (integers and floating-point)String— stringsBoolean— logical valuestrueorfalseUndefined— the value of a variable that has not been assigned a valueNull— a special value meaning "no value"Symbol— unique and immutable identifiersBigInt— integers of arbitrary length
-
Objects:
Object— a collection of key-value pairs- Arrays, functions, dates, and other structures are objects in JavaScript
Example of defining variables with different types:
let num = 42; // Number
let str = "Hello"; // String
let flag = true; // Boolean
let undef; // Undefined
let empty = null; // Null
let sym = Symbol('id'); // Symbol
let big = 9007199254740991n; // BigInt
let obj = { name: "Ivan" }; // Object