JavaScript, being a dynamically typed language, supports several data types.
Primitive Data Types:
- Number: Represents numeric values, both integers and floating-point numbers.
- String: Represents sequences of characters, enclosed in single or double quotes.
- Boolean: Represents a logical value, either
true
orfalse
. - Undefined: Represents a variable that has been declared but not assigned a value.
- Null: Represents the intentional absence of any object value.
- Symbol: Introduced in ECMAScript 6 (ES6), represents a unique identifier.
Non-primitive Data Type:
- Object: Represents a collection of key-value pairs, where values can be of any data type (including other objects), and accessed by keys.
Special Data Types:
- Function: In JavaScript, functions are first-class citizens and can be assigned to variables, passed as arguments, and returned from other functions.