JavaScript basic Syntax confusing place Summary _ basics

Source: Internet
Author: User
Copy Code code as follows:

/*
JS Basic Grammar, a few more easily confusing place.
*/
/*
==
===
*/
Function de () {
var ab = 25; Numerical
var ba = "25"; String
if (ab = = ba) {//==, will be converted first, after the pair.
Alert ("B");
}
if (!) ( AB = = ba)) {//=== will not convert, and direct alignment, AB is numeric type data, and BA is string type data
Alert ("a");
}
}
/*
!b
!! B
*/
function dd () {
var b= 1;
if (!! b) {//! when it is not 0 value, so return FALSE, when!! , a further Boolean () method is followed, then the Boolean value is reversed, and the value is obtained.
Alert ("a");
}
}
/*
parseint parsefloat
*/
Function Parse () {
var a = "18px";
var B = parseint (a); return value 18
var C = parseint (A, 10); Return a value of 18, you can pass parameters, the system
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 the value is converted, that is, the number after the first decimal point is preserved, but the second decimal point is ignored.
Parsefloat also ignores the 0 at the first position.
*/
}
Window.onload = function () {
Parse ();
DD ();
De ();
}
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.