What is the difference between a three equals sign and two equals sign in JavaScript?

Source: Internet
Author: User

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

A) comparison between the different types, = = Comparison of "converted to the same type of value" see "Value" is equal, = = = If the type is different, the result is unequal

b) Comparison of the same type, direct "value" comparison, the results of the same

such as alert (' 1 ' ==1);//result is true
Alert (' 1 ' ===1);//result is False

2, for Array,object and other advanced types, = = and = = = There is no difference between

Make a "pointer address" comparison

3, the basic type and the advanced type, = = and = = = There is a difference

a) for = =, advanced conversion to the underlying type for "value" comparison

b) = = = = False due to different types

Such as

var a = new string (' 1 ');//defines a high-level type of string
var b = ' 1 ';//set an underlying type string
alert (b==a);//True
alert (b===a);//Is False

What is the difference between a three equals sign and two equals sign in JavaScript?

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.