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

> after all, a 1 is a 1 even if it happens to be a string

Is it? In JS: "1" + 1 == "11"; 1 + 1 == 2



The problem there isn't with coercion, it's with + being both addition and concatenation, as I mentioned at the end of my comment.

If you use any other operator (any reasonable operator), it works: "1" - 1 === 0, "1" - "1" === 0 and 1 - 1 === 0.




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: