VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-data-types/

⇱ JavaScript Data Types - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Data Types

Last Updated : 19 Jan, 2026

JavaScript data types define what kind of values a variable can hold and how those values behave in a program. They determine how data is stored in memory and how operations like comparison, calculation, and conversion work.

  • Each data type has its own methods and operations that control how it can be used.
  • Understanding data types helps prevent errors and makes code more efficient and reliable.

JavaScript Data Type Categories

JavaScript data types are categorized into Primitive and Non-Primitive types

👁 data_types_in_javascript

Primitive Data Type

Primitive data types in JavaScript represent simple, immutable values stored directly in memory, ensuring efficiency in both memory usage and performance.

1. Number

The Number data type in JavaScript includes both integers and floating-point numbers. Special values like Infinity, -Infinity, and NaN represent infinite values and computational errors, respectively.

2. String

A String in JavaScript is a series of characters that are surrounded by quotes. There are three types of quotes in JavaScript, which are.

3. Boolean

The boolean type has only two values i.e. true and false.

4. Null

The special null value does not belong to any of the default data types. It forms a separate type of its own which contains only the null value.

The 'null' data type defines a special value that represents nothing, or empty value.

5. Undefined

A variable that has been declared but not initialized with a value is automatically assigned the undefined value. It means the variable exists, but it has no value assigned to it.

6. Symbol (Introduced in ES6)

Symbols, introduced in ES6, are unique and immutable primitive values used as identifiers for object properties. They help create unique keys in objects, preventing conflicts with other properties.

7. BigInt (Introduced in ES2020)

BigInt is a built-in object that provides a way to represent whole numbers greater than 253. The largest number that JavaScript can reliably represent with the Number primitive is 253, which is represented by the MAX_SAFE_INTEGER constant.

Non-Primitive Data Types

The data types that are derived from primitive data types are known as non-primitive data types. It is also known as derived data types or reference data types.

1. Object

JavaScript objects are key-value pairs used to store data, created with {} or the new keyword. They are fundamental as nearly everything in JavaScript is an object.

2. Arrays

An Array is a special kind of object used to store an ordered collection of values, which can be of any data type.

3. Function

A function in JavaScript is a block of reusable code designed to perform a specific task when called.

4. Date Object

The Date object in JavaScript is used to work with dates and times, allowing for date creation, manipulation, and formatting.

5. Regular Expression

A RegExp (Regular Expression) in JavaScript is an object used to define search patterns for matching text in strings.

Interesting Facts about Data Types

1. Dynamically Typed : JavaScript Variables are not bound to a specific data type. Mainly data type is stored with value (not with variable name) and is decided & checked at run time.

2. Everything is an Object (Sort of): In JavaScript, Functions are objects, arrays are objects, and even primitive values can behave like objects temporarily when you try to access properties on them.

3. NaN is not equal to itself: NaN Stands for “Not-a-Number”, It is used to represent a computational error. NaN is technically of type number.

4. A Symbol is Never Equal to Another One : Symbol is a unique and immutable data type often used for creating private properties and methods. Symbols are never equal to any other Symbol.

5. Undefined and Null: undefined represents a variable that has been declared but not assigned, while null is an explicit assignment representing “no value”.

6. Integers are Floating are Numbers only. There is only one type number that covers both integers and floating point numbers.

7. A character is also a string. There is no separate type for characters. A single character is also a string.

Comment