R
R
Ruslan2021-06-09 07:33:05
JavaScript
Ruslan, 2021-06-09 07:33:05

How is type casting done with non-strict equality?

How does such a comparison take place? Why does the console output truein such a comparison?
console.log(!!"false" == !!"true");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-06-09
@Romario5891

Non-empty strings in logical operations (you use boolean negation) are cast to true.
(!!"false" == !!"true") → (!!true == !!true) → (!false == !false) → (true == true) →
true nothing to do with it, you have both values ​​​​when compared, they have the same type, boolean.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question