0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>And now we fixed the second version of the analyzer. But the boss heard somewhere about the theory of evaluation with the help of equalities and inequalities. The Muffin needs for the analyzer to compare the markers of the same color according to the new rules, and the cat quickly executed this logic. And again, the rule “where the paws are fast, bugs are plenty” worked.</p>
1
<p>And now we fixed the second version of the analyzer. But the boss heard somewhere about the theory of evaluation with the help of equalities and inequalities. The Muffin needs for the analyzer to compare the markers of the same color according to the new rules, and the cat quickly executed this logic. And again, the rule “where the paws are fast, bugs are plenty” worked.</p>
2
<p>To fix this program, we need to go deeper into the comparison operators. To find out whether two values are equal or not, JavaScript uses the ==, !=, === and !== operators.</p>
2
<p>To fix this program, we need to go deeper into the comparison operators. To find out whether two values are equal or not, JavaScript uses the ==, !=, === and !== operators.</p>
3
OperatorNameAction==Approximate equality (with casting types)Compares two values, before this casts one of the values to the type of the other. If the values are equal, it returns true.===Strict equality (without casting types)Compares two values. If the value types are different or the values are not equal, it returns false.!=Inequality (with casting types)Compares two values, before this casts one of the values to the type of the other. If the values are not equal, it returns true.!==Strict inequality (without casting types)Compares two values. If the value types are different or the values are not equal, it returns true.<p>What does “casts or does not cast values to one type” mean? Let’s look at the examples.</p>
3
OperatorNameAction==Approximate equality (with casting types)Compares two values, before this casts one of the values to the type of the other. If the values are equal, it returns true.===Strict equality (without casting types)Compares two values. If the value types are different or the values are not equal, it returns false.!=Inequality (with casting types)Compares two values, before this casts one of the values to the type of the other. If the values are not equal, it returns true.!==Strict inequality (without casting types)Compares two values. If the value types are different or the values are not equal, it returns true.<p>What does “casts or does not cast values to one type” mean? Let’s look at the examples.</p>
4
console.log('123' == 123); // Returns true console.log('123' != 123); // Returns false<p>The string and the number will be equal to each other. This is the case, because comparing different types with == converts values to a single type. For example, you can get 123 from the '123' string. And the number 123 is equal to the number 123, that is why the comparison returns the true value. For the same reason, the inequality != returns false for these value: they can be brought to one type and then they will be equal to each other.</p>
4
console.log('123' == 123); // Returns true console.log('123' != 123); // Returns false<p>The string and the number will be equal to each other. This is the case, because comparing different types with == converts values to a single type. For example, you can get 123 from the '123' string. And the number 123 is equal to the number 123, that is why the comparison returns the true value. For the same reason, the inequality != returns false for these value: they can be brought to one type and then they will be equal to each other.</p>
5
console.log('123' === 123); // Returns false console.log('123' !== 123); // Returns true<p>In this case, the result is the opposite. Strict equality === does not lead to values of the same type, but compares them as is: a string and a number. A string, whatever value it contains, is not equal to a number, that is why a comparison for equality returns false. But a strict inequality for such values returns true.</p>
5
console.log('123' === 123); // Returns false console.log('123' !== 123); // Returns true<p>In this case, the result is the opposite. Strict equality === does not lead to values of the same type, but compares them as is: a string and a number. A string, whatever value it contains, is not equal to a number, that is why a comparison for equality returns false. But a strict inequality for such values returns true.</p>