Summary of the basic JavaScript syntax-js tutorial

Source: Internet
Author: User
Summary of the basic JavaScript syntax is confusing. Learn about JavaScript. The Code is as follows:


/*
In the Basic JS syntax, there are several confusing points.
*/
/*
=
===
*/
Function de (){
Var AB = 25; // Value
Var ba = "25"; // string
If (AB = ba) {// =, it is converted first and then compared.
// Alert ("B ");
}
If (! (AB = ba) {// = does not convert, but performs direct comparison. 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 (a); // return the value 18.
Var c = parseInt (a, 10); // return 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.