Back to Library
Region:
Switch to ID
Beginner freeCodeCamp • introduction-to-javascript
What Is a Data Type, and What Are the Different Data Types in JavaScript?
Lesson Overview
In programming, a **Data Type** defines the kind of data a value can hold and what operations can be performed on it. JavaScript is a **dynamically typed** language, meaning you don't have to speci...
In programming, a Data Type defines the kind of data a value can hold and what operations can be performed on it. JavaScript is a dynamically typed language, meaning you don’t have to specify the type of a variable when you create it.
The 7 Primitive Data Types
JavaScript has 7 primitive types:
- String: Represents textual data. Wrapped in single quotes (
'), double quotes ("), or backticks (`).- Example:
"Hello, World!"
- Example:
- Number: Represents both integer and floating-point numbers.
- Example:
42or3.14
- Example:
- Boolean: Represents a logical entity with two values:
trueandfalse. - Undefined: A variable that has been declared but not yet assigned a value.
- Null: Represents the intentional absence of any object value.
- BigInt: Used for numbers larger than the standard Number type can handle.
- Symbol: A unique and immutable value used as a property key for objects.
Complex Data Types
- Object: A collection of properties. Arrays and Functions are also technically types of objects in JavaScript.
Understanding these types is essential because JavaScript behaves differently depending on the type of data you are working with (e.g., adding two numbers vs. concatenating two strings).