<javascript Advanced Programming > Notes

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.