One, JavaScript data type
The data types of JavaScript fall into the following categories:
Five simple data types: Undefined,null,boolean,string,number.
A complex data type: Object.
Second, typeof operator
Here are a few short stories to summarize it, before summing up, first know a very useful operator--typeof.
The typeof operator is an operator used to detect JavaScript data types, which returns one of the above data types. But there is a special case where the null data type returns object, that is, typeof null to return an object. This is because NULL is understood to be an empty object reference. This involves two large data types, null and undefined. We recognize and differentiate them below.
Third, Boolean
The Boolean value has only two literals: true and false. This type uses quite a lot, note that these two literals are not equal to the values 1 and 0, and that true and false are case-sensitive, that is, true is not a Boolean value, but a simple identifier.
When you want to convert a value to a Boolean value, you can call the Transform function Boolean (), and for any type of data using a transform function, you can convert them to a Boolean value, and all types of data are converted with the corresponding conversion rules. Not listed here, to cite a few examples:
Boolean (""); False
Boolean (O and Nan); False
Boolean (NULL); False
Boolean ("Hello world!"); /true;
Iv. null and undefined
Both null and undefined are data types that have only one value, and undefined represents the value of an uninitialized variable, which is
var//true;
And null represents an empty object pointer, so this is why typeof null returns object.
In fact, undefined is derived from Null,so, alert (null = = undefined) , and returns True.
This article ends with two other types of data.
JavaScript data type (i)--typeof operator, Boolean, NULL, and undefined