1. To say that a value is converted to its corresponding Boolean type, you can call the Transform function Boolean ().
var message= "Hello world! "; var messageasboolean=boolean (message);
2. Floating point number
If a floating-point value represents a value, then he will be saved as an integer,
var floatnum=10.0; //Integer , which resolves to 10.
3. By default, ECMAScript converts a floating-point value with more than 6 digits after the decimal point to a numeric value expressed in E notation.
The highest precision of a floating-point value is 17 bits, and his calculation accuracy is far from the integer high, and the result of 0.1+0.2 is not 0.3 but 0.300000000000004,
if(0.1+0.2=0.3) { //...} // never judge a floating-point value.
4.NaN is not equal to any value, including itself,
alert (Nan==nan); // false
Determine NaN, function isNaN (): The arguments passed in will attempt to convert to numeric values, and if the conversion fails, the function returns a true value.
/* The IsNaN () function also applies to objects, and when the IsNaN () function is called based on an object, the object ValueOf () method is called first, and then the value returned by the method can be converted to a number. If not, then the ToString () method is called based on this return value, and the return value is tested. */
5. Numeric conversions: Number (), Paresint (), and parsefloat ().
The transformation function can be used for any data type, while the other two functions are designed to convert a string into a numeric value.
var num=number (' 0011 '); // 11, ignoring its leading 0,
There is no method in the program to represent the binary number, only 16 binary notation. The 0x+ represents 16 binary, and 0+ represents 8 binary.
Parsefloat () parses only the decimal number, without the second argument, he will always ignore the leading 0,
parseint () contains the second parameter, which determines the number of binary numbers.
<javascript Advanced Programming > Notes