Data types define what forms of data may be stored and handled within a program.
Primitive data types can only store a single value at a time, whereas composite data types can store collections of values as well as more complex entities. Let's go over each one in detail.
The number data type is used to represent positive or negative values with or without a decimal point, as well as numbers expressed in exponential notation, for example, 1.5e-4 (equivalent to 1.5x10-4). Infinity, -Infinity, and NaN are all special values in the Number data type. Infinity is the mathematical infinity that is greater than any number.
The Boolean data type has only two possible values: true or false. It is commonly used to hold values such as yes (true) or no (false), on (true) or off (false), and so on. Boolean values are also the outcome of comparisons in a Program.
An array is a type of object that allows you to store several values in a single variable. Each value (also known as an element) in an array has a numeric location known as its index and can include any data type-numbers, texts, booleans, functions, objects, and even other arrays. The array index begins at zero, so the first array element is arr, not arr.
An object is a sophisticated data type that allows you to save data collections. An object has properties, which are specified as a key-value pair. A property key (name) is always a string, but the value can be any data type, including strings, integers, and booleans, as well as sophisticated data types such as arrays, functions, and other objects. Objects will be covered in greater detail in subsequent chapters.
The undefined data type can only have one value the undefined special value. If a variable is declared but not assigned a value, its value is undefined.
A function is a callable object that performs code. Because functions are objects, they may be assigned to variables.
8. Empty Value
Another data type that can only have one value the null value. A null value indicates that no value exists. It's not the same as an empty string (" ") or 0 it's just nothing.