Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation of first example is wrong #316

Open
salmanarshad2000 opened this issue Sep 1, 2023 · 1 comment
Open

Explanation of first example is wrong #316

salmanarshad2000 opened this issue Sep 1, 2023 · 1 comment

Comments

@salmanarshad2000
Copy link

Explanation of this example is wrong:
https://github.com/denysdovhan/wtfjs#-is-equal-

The abstract equality operator converts both sides to numbers to compare them

This is just wrong. Strings are compared as strings, null compared to undefined is true, to-primitive might return a string instead on number and so on.

Here is how this expression simplifies:

+[] == +![];

First step would be to convert ![] to false because of precedence.

@tidalu
Copy link

tidalu commented Nov 29, 2023

so, overall, your state is absolutely correct , but here is the thing, [] == ![] , for this problem, even though ![] is firstly converted to boolean, there what the author meant is both sides are converted to numbers to be primitive both sides, :: If the types of the two operands are different, JavaScript attempts to convert them to a common type :: but your state is also true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants