JavaScript is a kind of dynamic data type language, the variable is not type, can randomly assign arbitrary value, if the variable to convert data type, there are two ways: implicit conversion
and an explicit conversion.
Implicit conversions can be converted to strings (adding a value to a string) number (using the plus operator before the value or using the minus, multiply, divide, modulo operators) Boolean values
(use non-in front of the value!) Operator two times)
Explicit type conversions (more important)
Force conversion to Digital
The parseint () function parses a string and returns an integer.
The parsefloat () function resolves a string and returns a floating-point number.
Number () function, you can convert any type of value into numbers.
Cast to String
String () function to convert any type of value into a string.
Cast to a Boolean value
Boolean () function, you can convert any type of variable to a Boolean value.
The conversion result for the following five values is false:undefined null 0 NaN "" and the other values are all true.
JS Conversion Data type