ECMAScript: Standard, Core
HTML Tag type: block, inline, inline-block, table ...
The data type in JS: Number, String, Boolean, function, object (obj, [], {}, null), undefined
Ii. typeof Judging data types
- "Undefined" If this value is not defined
- "Boolean" If this value is a Boolean value
- "String" If this value is a string
- "Number" If this value
- "Object" If this value object or null
- ' function ' If this value function
such as Var a=123;
Alert (typeof a)//number
Third, numerical conversion
Explicit type conversions (coercion type conversions): A total of three functions
Conversion rules for number () functions
If it is a Boolean, True and False are converted to 1 and 0, respectively.
If it is a numeric value, simply pass in and return
If it is a null value, returns 0
If it is undefined, return Nan
L if it is a string, follow these rules
1) If the string contains only numbers (including those preceded with a sign), it is converted to a decimal value [first bit in front if with 0 direct ignore]
2) If the string contains a valid floating-point format, it is converted to the corresponding floating-point value [front first bit if with 0 direct ignore]
3) If the string contains a valid hexadecimal format, convert it to a decimal integer value of the same size
4) If the string is empty (does not contain any characters), convert it to 0
5) If the string contains characters other than the above format, convert it to Nan
parseint () function conversion rules take integers only
When a string is converted, the spaces preceding the string are automatically ignored until the first non-whitespace character is found
Note: 1) If the first character is not a numeric character or a minus sign, it will return Nan
2) If the first character is a numeric character or minus sign, the second character will continue to be parsed until it is resolved or a non-numeric character is encountered
Parsefloat () function conversion rules
Note: Only the first decimal point in a string is valid
Implicitly-Typed conversions:
+ 200+ ' 3 ' into a string
-*/% ' 200 '-3 becomes a number
++--into numbers.
Comparison of >< numbers, Comparison of strings
! Turn the data type on the right to a Boolean value
JS4 data types, type conversions