Number - A number, either integer or floating-point.
Boolean - A value of true or false.
Null - A value that indicates that a variable has no value.
Undefined - A value that indicates that a variable has not been assigned a value yet.
BigInt - A 64-bit integer.
Symbol - A unique identifier.
In addition to these primitive data types, JavaScript also has objects, which are complex data structures that can contain any combination of primitive and object types.
The type of a variable is determined by the value that is assigned to it. For example, if you assign the string "Hello, world!" to a variable, the type of the variable will be "string".
You can use the typeof operator to determine the type of a variable. For example, the following code will print the type of the variable
myVar:
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
JavaScript has seven primitive data types:
In addition to these primitive data types, JavaScript also has objects, which are complex data structures that can contain any combination of primitive and object types.
The type of a variable is determined by the value that is assigned to it. For example, if you assign the string "Hello, world!" to a variable, the type of the variable will be "string".
You can use the
typeofoperator to determine the type of a variable. For example, the following code will print the type of the variablemyVar:The
typeofoperator can also be used to determine the type of an object. For example, the following code will print the type of the objectmyObject:Here is a table that summarizes the different data types in JavaScript and how to determine their type:
typeofoperator