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

> cell[0][0] is "0", cell[1][1] is 0, cell[2][2] is true

If those values came from <input> elements, the second and third examples aren't possible without having manually converted it beforehand. Input values are always strings, even a checkbox. That's where javascript's conversion rules and lax equality came from, an attempt to have sane defaults for simple uses: If a string is being compared to a number, the string is likely from an input and the number was typed into the code, so convert the string to a number before comparison.



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

Search: