One, the data types in JavaScript can be divided into basic data types and composite data types two kinds:
(1) The underlying data type has 5 data types: number, Boolean, Undefined, NULL, and string.
Number type: Integers and floating-point numbers. Nan:not a number. This value is used to return a value, but it is not possible to put back a value to prevent an error. For example: 1/0 the return is Nan. Nan Features: 1. Any operation involving Nan will return Nan. 2. Nan is not equal to any value, including its own Nan itself. For the Nan attribute, JS has a built-in isNaN () function to determine whether the value is a Nan type.
Boolean type: Only two literal literals are true and false. However, many variables in JS can be converted to a Boolean value using the Boolean () function.
UndefinedThe type has only one value, that is, undefined, which declares the variable using VAR, but is not initialized, and this variable is the undefined type, for example:
var i;
alert (i = = undefined);//true
var i; var i = undefined; the two sentences are equivalent.
variables that contain undefined values are not the same as undefined variables.
the Null type also has only one value: Null.null represents a pointer to an empty object.
StringType: Slightly(2) composite data types include the following:
functionfunction Type [*]
ObjectObject types, Object essence is a set of unordered name-value pairs.
ArrayThe array type, which is a special type of object object, checks the data type of a variable
typeof operator: The type of the inferred variable for a variable, possibly returning the following string:
"undefined": if this value is undefined or initialized
"Boolean": Boolean value
"string": String
"number": Value
' object ': Object
"function": Functions
usage: typeof 95; or typeof (95); will return "number"Example code:
JS data type