The basic JavaScript syntax is confusing.

Source: Internet
Author: User
        /*  In the Basic JS syntax, there are several confusing points.  */          /*  =====  */          Function  De (){  VaR AB = 25; //  Value              VaR BA = "25 "; //  String              If (AB = BA ){//  =, Which is converted first and then compared.                  //  Alert ("B ");  }  If (! (AB = BA )){ //  ===Without conversion, direct comparison is performed. AB is a numerical data, while Ba is a string data.                  //  Alert ("");  }}  /*  ! B !! B  */          Function Dd (){  VaR B = 1 ;  If (!! B ){ //  ! It is not 0, so false is returned. When !! Then, the Boolean () method is further involved, and then the inverse of the Boolean value is obtained.                  //  Alert ("");  }}  /*  Parseint parsefloat  */          Function  Parse (){ VaR A = "18px" ;  VaR B = parseint (); //  Return Value 18              VaR C = parseint (A, 10 ); //  Returns the value 18. You can pass the parameter in hexadecimal notation.              //  Alert (B );  Alert (C );  VaR E = "18.2px" ;  VaR D =Parsefloat (E); alert (d)  /*  The difference between parseint and parsefloat is that the first decimal point is not ignored when parsefloat is converted. That is to say, the number after the first decimal point is retained, but the second decimal point is ignored. Parsefloat also ignores the 0 at the first position.  */  } Window. onload = Function  () {Parse (); dd (); De ();} 

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.