varnum = 1;

varstr = ‘1’;

vartest = 1;

Test == num //true Same type same value

Test === num //true Same type same value

test ! == num //false Test has the same type and value as num. The non-operation must be false

Num == STR //true Converts STR to a number and checks if it is equal.

num ! = STR //false = non-operation of =

Num === STR //false False is returned depending on the type

num ! == STR //true num and STR are of different types, meaning they are not equal

= = and! = Comparison If the types are different, try the conversion type first, then perform a value comparison, and finally return the value comparison result.

while

= = = and! == Only values of the same type are compared.

=== = equality == equality

==, if the two values have different types, type conversion should be performed before comparison.

===, do not do type conversion, different types must vary.

The following are explained separately:

Let’s start with lambda = lambda = lambda, which is a little bit easier. The following rule is used to determine if two values are equal:

1, if the type is different, it is not equal.

2, If both of them are numbers and have the same value, then they are equal. (! The exception is if at least one of them is a NaN, then [not equal]. (isNaN() is the only way to determine if a value is a NaN.)

3, if both are strings and the characters in each position are the same, then [equal]; Otherwise [unequal].

4, If both values are true or false, then [equal].

5, If two values refer to the same object or function, then [equal]; Otherwise [unequal].

6, if both values are null or undefined, then [equal].

Say ==, according to the following rules:

1. If two values are of the same type, compare ===.

2. If two values have different types, they may be equal. Use the following rules to cast and compare:

A, if null and undefined, then [equal].

B. If one is a string and the other is a number, convert the string to a number and compare.

C, if any value is true, convert it to 1 and compare; If either value is false, convert it to 0 and compare.

D. If one is an object and the other is a number or string, convert the object to a value of the underlying type and compare. The object is converted to the base type using its toString or valueOf methods. The js core built-in class will try valueOf before toString; The exception is Date, which utilizes the toString conversion. Non-js core object, make said (more trouble, I also do not understand)

E, any other combination is [unequal].

For example:

“1” == true

1 == 1; 1 == 1; 1 == 1; 1 == 1;

= assignment operator

= = is equal to the

=== strictly equal to

Ex. :

var a = 3;

var b = “3”;

A = = b returns true

A = = = b returns false

Because a and B have different types

=== is used to make strict comparative judgments

vardata = ({“val”:”7″,”flag”:”true”});

How do I determine the value of flag?

Because true in double quotes == presumably is the string true

Without double quotes === is the Boolean value true

This is important, and I haven’t figured this out before

Write 1

1 the if (data flag = true) {… }else{.. }

I don’t know how it works, I don’t get the else value at all, and the reason is that this is the same thing as, okay

1 the if (true) {… }

Write 2

1 the if (data flag = = true) {… }else{.. }

There’s no such thing

Writing 3

1 the if (data flag = ‘true’) {… }else{.. }

I don’t know how it works, I don’t get the else value at all, and the reason is that this is the same thing as, okay

1 the if (true) {… }

Write 4

1 the if (data flag = = ‘true’) {… }else{.. }

This is the correct way to write it

“=” : This indicates assignment, not operator

“==” : equal to (value)

“===” : indicates full equality (type and value)