Data types are concepts to be able to operate on variables.
JavaScript variables can hold Data types like Strings, numbers, arrays, and so on.
Strings
Strings are written in double quotes(" ") or single quotes(' ').
In the image below..you can use a double quote and single quote interchangeably or when using two double quotes or a single quote in a sentence, a backslash can be used in front.
Number
For the number data type, It is either a negative or a positive number. It can also be a decimal number.
Booleans
In boolean, It is either true or false, Yes or no, off or on.
Arrays
It is used to store a list of data. Arrays are written using square brackets [ ].
An array can be written inside another array.Arrays can be accessed by their index. Every array has an index that starts with 0.
Objects
The object is a data type that allows the storage of collections of data. They are denoted using square brackets { }.
To access the data of an object: ObjectName.keyName
Undefined
If a variable has been declared but has not been assigned a value, has the value undefined.
Top comments (0)