JavaScript full equals operator use description _ Basics

Source: Internet
Author: User
and has always been using the equal sign "= =" has not been used in JS all equal to the symbol "= =". While these two operators only detect the equality of two objects, one performs a type conversion and one type does not convert, all equals the symbol returns true only before the type is not converted

Copy Code code as follows:

var snum= "66";
var inum=66;
alert (snum==inum);//Output is true
alert (snum===inum);//output is False

The first equals operator converts the value of Snum "66" to a numeric type at the time of comparison, and then returns True when compared to Inum.
The second full equals comparison has no type conversions, so the string and numeric type comparisons cannot be true, and all returns false
There is also a non-full equal sign and a non equal

Copy Code code as follows:

var snum= "66";
var inum=66;
alert (snum!=inum);//Return to False
alert (snum!===inum);//Returns True

The first operator is well understood, the operator converts snum to a numeric type, and the two values are equal to the numeric type and return to False
The second operator does not convert the Snum type so that snum is not equal to Inum, so returns to True
This is also a study of my notes hehe.

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.