Sobes.tech
Middle

What types are there in JavaScript?

sobes.tech AI

Answer from AI

JavaScript has the following main data types:

  • Primitive types:

    • Number — numbers (integers and floating-point)
    • String — strings
    • Boolean — logical values (true or false)
    • Undefined — the value of a variable that has not been assigned a value
    • Null — a special value meaning "no value"
    • Symbol — unique and immutable identifiers
    • BigInt — for representing integers of arbitrary length
  • Objects:

    • Object — a collection of key-value pairs
    • Arrays, functions, dates, and other structures are objects with additional functionality

Example of defining variables of 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 bigIntNum = 9007199254740991n; // BigInt
let obj = { name: "Ivan" }; // Object
What types are there in JavaScript? — Frontend - sobes.tech