Sobes.tech
Junior — Middle

Can you list the main primitive and complex data types used in JavaScript?

sobes.tech AI

Answer from AI

In JavaScript, the following primitive data types exist:

  • Number — a numeric type, e.g., 42, 3.14
  • String — a string, e.g., "hello"
  • Boolean — a logical type: true or false
  • Undefined — the value of a variable that has not been assigned a value
  • Null — a special value indicating "absence of a value"
  • Symbol — a unique and immutable identifier
  • BigInt — for working with integers of arbitrary length

Complex data types in JavaScript are represented by objects:

  • Object — a collection of key-value pairs
  • Array — an ordered list of values
  • Function — an object that can be called
  • Date, RegExp, and other built-in objects

Example:

const num = 10; // Number
const str = "text"; // String
const flag = true; // Boolean
const obj = {name: "Ivan", age: 30}; // Object
const arr = [1, 2, 3]; // Array
Can you list the main primitive and complex data… - sobes.tech