"=" And "="

Source: Internet
Author: User

=,
The comparison rules are as follows:
1. If the types are different, [not equal]
2. If both are numerical values and the values are the same, [equal]; (exception) is: if at least one of them is Nan, [not equal]. (You can only use isnan () to determine whether a value is Nan)
Alert (Nan = Nan); // output "false"
Alert (Nan = Nan); // output "false"
3. If both are strings and the characters at each position are the same, [equal]; otherwise [not equal].
4. If both values are true or false, [equal].
Alert (5> 3) === (2 <3); // true
5. If both values reference the same object or function, [equal]; otherwise [not equal].
VaR He = function () {}, Se = He;
Alert (He = Se); // true
6. If both values are null or undefined, [equal].
VaR he, se
Alert (He = Se); // true

Besides,
The comparison rules are as follows:
1. If the two values are of the same type, the comparison rules are as follows:
2. If the two values have different types, they may be equal.
Perform type conversion and comparison based on the following rules:
A. If one is null and the other is undefined, [equal].
B. if one is a string and the other is a numerical value, convert the string to a numerical value before comparison.
C. If any value is true, convert it to 1 for comparison. If any value is false, convert it to 0 for comparison.
D. If one is an object and the other is a value or string, convert the object to a base type value before comparison. Converts an object to a base type and uses its tostring or valueof method.
JS core built-in class, will try valueof prior to tostring;
The exception is date, which uses tostring conversion.
Non-js core objects. (I don't know much about it)
E. Any other combinations (array, etc.) are [not equal].

"=" And "="

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.