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 ();
}