Hacker Newsnew | comments | show | ask | jobs | submitlogin

Nope:

    js> a = {}
    [object Object]
    js> b = {}
    [object Object]
    js> a == b
    false
== only casts between certain primitive types, it doesn't do a deep comparison:

    js> x = null
    null
    js> y = undefined
    js> x == y
    true
    js> x === y
    false
Also undefined comparisons are still true with ===:

    js> var _
    js> _ === undefined
    true

But you're right, === should be the default choice, and only use == if you have a good reason.



Guidelines | FAQ | Support | API | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: