let value1 = 42;let value2 = "42";console.log((value1 == value2) === (value1 === value2))
value1 holds a number
42 and another variable
value2 holds a string
42 inside it.
Now we want to log the resulting value of this expression, where double equals (
==) compare the
value2 using loose equality.
And this triple equals (
value2 using strict equality. We will see in a minute what loose in strict equality mean?
Finally, we log the results from loose and strict equality to see if they both return the same result.
When we use the double equals to compare
value2 it, implicitly convert the string
42 to number and compare them, which gives us the result
On the other hand, using strict equality with triple equals, there is no implicit type conversion and it treats a string as a string and a number as a number.
So when the quality check is performed between
value2, it returns
false. And finally, when
false are checked, using triple equals strict equality,
they return false, which is the actual output of this problem.