Data Types in JavaScript
Understanding data types is crucial for JavaScript developers.
They define what kind of data can be stored and how it can be
manipulated.
Primitive Data Types
Core building blocks Directly assigned
They represent single values, like numbers, strings, Primitive values are stored directly in memory,
or booleans. They are immutable, meaning their making them simple to access and manage.
values cannot be changed directly.
Number
1 Numerical values 2 Mathematical
operations
Represent integers, Used in calculations
decimals, and scientific and comparisons.
notation.
String
Text data Manipulation
Enclosed in single or double quotes. Can be manipulated with methods like
concatenation and slicing.
Boolean
1 Logical values 2 Conditional
statements
Represents truth (true)
or falsity (false). Used in conditional
statements to control
program flow.
Undefined
Absent value Default state
Indicates a variable has not yet been assigned a value. Variables are initialized with undefined before
being assigned.
Null
1 Intentional absence 2 Placeholders
Used as placeholders
Represents the for variables that will
intentional absence of a be assigned later.
value.
Symbol
Unique identifier Private properties
Creates unique,
immutable values, Helps create private
useful for object properties in objects,
property keys. ensuring data isolation.
Non-Primitive Data Types
Complex structures References
Represent collections of data, such as objects or Non-primitive values are stored as references in
arrays. They are mutable, meaning their values can memory, pointing to the actual data.
be changed.
Object
1 Key-value pairs 2 Real-world
representation
Store data as
collections of key-value Represent real-world
pairs, enabling complex entities with properties
data organization. and methods, like
objects in your code.