The difference between a JavaScript's conditional expression "= =" (equals) and "= = =" (Strictly equal To)

Source: Internet
Author: User

with "= =", if the two value types are different, they may be equal because the "= =" is converted by default, and the conversion rules are more complex:A , if one is null and one is undefined, then [equal]. B, if one is a string, one is a numeric value, the string is converted to a numeric value and then compared. C, if any value is true, convert it to 1 and then compare it to 0 if either value is false. D, if one is an object and the other is a numeric or string, convert the object to the value of the underlying type and then compare it. The object is converted to the underlying type, using its ToString or ValueOf method. JS Core built-in class, will try to valueof before ToString, the exception is that date,date is using the ToString conversion.  with "= = =", the types and values of two values must be equal, they are equal, and "= = =" does not convert data types when making comparisons.
Ten = = "Ten"  //  return True//  return False
It is recommended that you never use "= =".

The difference between a JavaScript's conditional expression "= =" (equals) and "= = =" (Strictly equal To)

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.