Suggest an editImprove this articleRefine the answer for “Data types in JS”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**Data types in JavaScript** total 8, split into **primitive** types (7) and a single **reference (object)** type. **Key point:** Primitive types (Number, BigInt, String, Boolean, Null, Undefined, Symbol) are stored by value, while Object is stored by reference.Shown above the full answer for quick recall.Answer (EN)ImageJavaScript has **8 basic data types**. They are split into **primitive** and **reference (object)** types. --- ## 1. Primitive types (7 total) A primitive is a value that **is not an object** and **has no methods**. They are stored **by value**, not by reference. --- ### **Number** **Numbers** - both integers and floating-point. ```javascript let a = 42; let b = 3.14; ``` Notes: - Special values exist: `Infinity`, `-Infinity`, `NaN` (Not-a-Number). - All numbers in JS are **64-bit floating-point numbers (IEEE 754)**. --- ### **BigInt** Used for **very large integers** that exceed the limits of `Number`. ```javascript let big = 123456789012345678901234567890n; ``` > Adds the `n` suffix. > Lets you work precisely with integers of any length. --- ### **String** Text strings in quotes: `'single'`, `"double"`, or `template` quotes. ```javascript let name = "Tim"; let message = `Hello, ${name}!`; ``` > Strings are **immutable** - a new string is created on any change. --- ### **Boolean** Logical values - `true` or `false`. ```javascript let isAdmin = true; let isLoggedIn = false; ``` > Used in conditions, checks, and logical expressions. --- ### **Null** A special value denoting **"nothing"** or **"empty"**. ```javascript let user = null; ``` > Its type is **object** (a historical mistake in JavaScript that stuck). --- ### **Undefined** A variable **declared but with no assigned value**. ```javascript let x; console.log(x); // undefined ``` > Assigned automatically when no value is set. --- ### **Symbol** A unique, immutable value often used as an **object key**. ```javascript let id = Symbol('id'); let obj = { [id]: 123 }; ``` > Every Symbol is unique, even with the same description. --- ## 2. Reference type ### **Object** Stores **collections of data and functions**. Passed **by reference**, not by value. ```javascript let user = { name: "Tim", age: 25 }; let arr = [1, 2, 3]; let func = function() {}; ``` Object subtypes: - `Object` - the base type. - `Array` - an array. - `Function` - a function. - `Date`, `RegExp`, `Map`, `Set`, and so on. | Data type | Example | Description | |---|---|---| | **Number** | `42`, `3.14`, `NaN` | Numbers | | **BigInt** | `123n` | Large integers | | **String** | `'Hello'`, `Hi ${name}` | Strings | | **Boolean** | `true`, `false` | Logical type | | **Null** | `null` | Absence of value | | **Undefined** | `undefined` | Not defined | | **Symbol** | `Symbol('id')` | Unique identifier | | **Object** | `{}`, `[]`, `function(){}` | Collections and structures |For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.