open_in_new Article on the Mozilla website .
Primitive values
Here is the updated table with comments added for each data type:
Here’s the filled comment for the Boolean data type:
| Data type | typeof return value |
Comment |
|---|---|---|
| Number | "number" |
Represents numeric values, including integers and floating-point numbers. |
| String | "string" |
Represents textual data enclosed in quotes (single, double, or backticks). |
| Boolean | "boolean" |
Represents logical values: true or false. Often used in conditional expressions and control flow. |
| Undefined | "undefined" |
Indicates a variable has been declared but not assigned a value. |
| Null | "object" |
Represents the intentional absence of anything. The typeof result is historically a bug but kept for compatibility. |
Objects
Here is the updated table with comments added for each data type:
| Data type | Comment |
|---|---|
| Object | Represents a collection of key-value pairs, where keys are strings or symbols, and values can be any data type. |
| Array | Represents an ordered collection of values, accessed by numeric indices. |
| Symbol | Represents a unique and immutable value, often used as object property keys to avoid name collisions. |
typeof
The open_in_new typeof() function can tell us a type of variable.
Andrew Dorokhov