Skip to content

Explanation of first example is wrong #316

Open
@salmanarshad2000

Description

@salmanarshad2000

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions