Home > Web Front-end > JS Tutorial > body text

Brief explanation of the difference between = = (equal) and = = = (all equal) in Javascript_Basic knowledge

WBOY
Release: 2016-05-16 17:36:47
Original
1179 people have browsed it

What is the difference between = = (equal) and = = = (all equal) in Javascript?

Let’s look at two examples first:

var n='100' ;

if(n==100)

 { 

alert('equal to');

}

else

                                        

alert('not equal to');

}

The result is "equal to";

When judging whether strings are the same,

var n=false;

if(n=='false')

                                                                              

alert('equal to');

         }

else

                                                             

alert('not equal to');

}

The result is "not equal to".

Reason: === When judging whether two values ​​are the same, it will first judge whether the data type is consistent. If the data type is consistent, it will continue to judge whether the content is the same. == When judging, the data type will be ignored and the judgment will be made directly. The content switch uses full equal judgment

In js, undefined and null are equal if == is used, and unequal if === is used.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template