Equality

    There are two kinds equality operators:

    • ===: strict equality comparison using "triple equals"
    • ==: loose or abstract equality comparison using "double equals", which first uses type coercion to convert values to the same type, and then compares them

    There's no built-in way to compare values for "structural equality" (e.g. comparing two arrays to see if they contain the same elements)

    Strict equality

    We should almost always use strict equality comparison with ===, since the behavior is more consistent.

    Loose equality

    Loose equality can be convenient, but is less consistent, so it's best to use === instead.

    Structural equality

    If we want to compare structural equality, we'll usually turn to a 3rd party library, such as lodash.isequal.

    SameValueZero

    Many built-in methods use the SameValueZero algorithm to test for equality, instead of == or ===. However, the differences are only relevant in edge cases, so it's generally safe to think of this as === equality.