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

I was only really referring to automatic type conversion for comparisons. That said, the example you gave sounds like the opposite, where you wanted it to do some auto-conversion and you're disappointed that it didn't? If I did 1 + "10" I don't think I'd want it to return 11!


I'd want it to throw some kind of cast exception, personally, not try and do what it thinks I want. (I'm not the GP)


It did convert the value. It converted the 1 to a string and added "10" to the end of it, resulting in "110" which then was converted to a float and used.

The error in this case would be forgetting Javascript's rules of implicit conversion.

Adding a float to a string results in a string.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: