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

I beg your pardon, but you do not 'need it in JS', if 'it' is referring to using === instead of == to compare strings.

Here is what node.js says:

    > "9223372036854775807" == "9223372036854775808"
    false


Ah but more fun with Javascript

>>> "9223372036854775807" == "9223372036854775808" false

>>> 9223372036854775807 == "9223372036854775808" true

>>> 9223372036854775807 == 9223372036854775808 true

I believe the grandparent post is more referring to "general" use cases then this one. Personally I now default to strict comparison operators both in JS and PHP unless I explicitly want a loose comparison and end up missing most of these strange vagaries these days.


Not in this case, but it's commonly accepted that == is "broken" in JavaScript, and === should be the equality operator of choice most of the time.

The one case where I sometimes use == is if I want to check for "null" or "undefined". Even then it scares me.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: