What are JavaScript Data Types?

551
february 22, 2023, at 23:13

JavaScript is a dynamically typed language, which means that data types are determined automatically based on the value of the variable. There are six primitive data types in JavaScript:

Number

This data type represents numeric values, both integers and floating-point numbers. Examples of numbers are 3, 3.14, -5, and Infinity.

String

This data type represents textual values, enclosed in quotes (single or double). Examples of strings are "Hello, world!", "42", and 'JavaScript'.

Boolean

This data type represents logical values, either true or false.

Undefined

This data type represents a variable that has been declared but has not been assigned a value.

Null

This data type represents the intentional absence of any object value.

Symbol

This data type represents a unique and immutable value that may be used as the key of an Object property.

In addition to these primitive data types, JavaScript also has one complex data type:

Object

This data type represents a collection of key-value pairs, where the key is a string and the value can be any data type (including other objects). Objects can be created with curly braces {} or the Object constructor function. JavaScript also has a seventh data type called BigInt, introduced in ES2020, which represents integers with arbitrary precision.