10 biggest JS pitfalls

Axel Rauschmayer axel at rauschma.de
Mon Dec 31 09:58:57 PST 2012

> Personally, I have issues with from- and to-String conversions when working with HTML form field values and data-* attributes. More precisely, I am careful to make these conversions manually, and I regret that JS doesn't warn me if I forget to do them. Indeed the following cases are problematic:
> * String-to-Number : not triggered in, e.g.,  x + '1' when x is a Number.

I would assume the opposite being a problem: The user enters the number '33' in a form field, you try to add 1, but forget that it is a string and end up with '331' instead of 34.

> * Boolean-to-String, Null-to-String: false and null are not converted to a falsy string.

When does this happen? Can you explain?



Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121231/4951bd87/attachment.html>

More information about the es-discuss mailing list