Every value in JavaScript belongs to a specific data type. Understanding how JavaScript categorizes, stores, and evaluates data types is essential for debugging type coercion and memory references.
JavaScript divides its data types into two distinct categories:
+-----------------------------------------------------------------------------+ | JAVASCRIPT DATA TYPES | +-----------------------------------------------------------------------------+ | | | 1. PRIMITIVE TYPES (7 Types) 2. REFERENCE TYPES (Objects) | | - Stored directly in the Call Stack - Stored in the Memory Heap | | - Immutable (cannot be altered in place) - Mutable | | - Compared by VALUE - Compared by REFERENCE | | | | * string * number * boolean * Object | | * null * undefined * symbol * Array (Specialized object) | | * bigint * Function (Callable object) | +-----------------------------------------------------------------------------+
stringTextual data enclosed in single quotes '...', double quotes "...", or backticks `` ... ``:
numberRepresents both integers and floating-point numbers (64-bit IEEE 754 floats):
bigintFor arbitrarily large integers beyond JavaScript's safe integer limit ($2^{53} - 1$ or 9,007,199,254,740,991):
booleanLogical values: strictly true or false:
undefinedA variable that has been declared, but has not yet been assigned a value:
nullRepresents the intentional absence of any object value:
symbol (ES6)A unique, immutable identifier used as unique object keys:
typeof Operator and the Famous BugUse the typeof operator to inspect the data type of any variable:
0. null was represented as a NULL pointer (0x00), causing typeof null to incorrectly return "object". This bug cannot be fixed now because doing so would break millions of legacy websites!Understanding this difference prevents 90% of beginner logic bugs:
typeof null in JavaScript?undefined and null?let obj2 = obj1;)?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Variables: var, let, const | Comments and Best Practices |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.