On the difference _javascript skills between "= =" and "= =" in JavaScript

Source: Internet
Author: User

Before using JavaScript, you will occasionally encounter the use of = = and = = Two symbols to determine whether two variables are equal. But the difference between the two symbols has not been investigated. Today I met the symbol = = =, so I decided to check the difference between the two.

In JavaScript there are "= =" and "= =" Two comparison operators, then what is the difference between them?

First, for String,number and other basic types, = = and = = There is a difference

1 different types of comparisons, = = comparison "into the same type of value" to see whether the "value" is equal, = = = If the type is different, the result is unequal
2 the same type of comparison, directly to the "value" comparison, the results of the same

Second, for Array,object and other advanced types, = = and = = is no difference

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

Three, the base type and the advanced type, = = and = = There is a difference

1 for = =, the advanced conversion to the underlying type, for "value" comparison
2 because the type is different, = = = The result is False

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.