Differences between "=" and "=" in Javascript _ javascript skills

Source: Internet
Author: User
This article mainly introduces the differences between "" and "" in Javascript, which is very comprehensive. we recommend this article to our friends when using JavaScript, from time to time, you may encounter the use of the = and = symbols to determine whether the two variables are equal. However, the differences between the two symbols have not been investigated. Today I met the = symbol, so I decided to check the difference between the two.

In Javascript, there are two comparison operators: "=" and "=". what are their differences?

1. for basic types such as string and number, ==and ===are different

1) compare different types, = to compare "convert to the value of the same type" to see if "value" is equal, = if the type is different, the result is not equal
2) compare the same type and directly compare the values. The results are the same.

2. for advanced types such as Array and Object, there is no difference between ==and ==

When a variable is defined as Arrary and a variable is defined as the Object type, but its value is the same, the result of the comparison of = and = is the same, because it is used for "pointer address" comparison

3. the basic and advanced types, ==and ==are different

1) For =, convert the advanced type to the basic type for "value" comparison
2) the result of ===is false because of different types.

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.