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

I believe it's because in JavaScript some values or expressions are "truthy" or "falsey" depending on how they are evaluated.


Many languages work like that and a lot of the issues people point out with JS are applicable to many scripting languages. Usually people point out Maths problems...aka problems with floats, which isn't really a JS problem.

People also point out stuff like `[]+[]` where Array addition operator is not overloaded to handle it at all because the correct way is to use `.concat` so I think by default duck typing comes into play and in most cases with that in JS the preferred type is string.

I do wish that there was a "cleaner" spec of JS that wasn't as backwards compatible but fixed all of the gotchas and filled in every gap but there doesn't seem to be much call for it atm.




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

Search: