Hacker News new | ask | show | jobs
by electrosphere 625 days ago
I believe it's because in JavaScript some values or expressions are "truthy" or "falsey" depending on how they are evaluated.
1 comments

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.