3 ms·
In the early days of my JavaScript'n I always used minus instead of plus when doing addition. But as the language and tools has matured I hardly see any type er
by z3t4 11y ago
In the early days of my JavaScript'n I always used minus instead of plus when doing addition. But as the language and tools has matured I hardly see any type errors any more. I do have a habit of parseInt() that won't easily go away though :P
Besides the concatenation of numbers to strings and vice versa, most other type errors in JavaScript will give you a syntax error or something like NaN (Not a Number).
So don't mix strings and numbers. Everything else is just "objects". =)
One thing that causes lots of bugs though is undefined object properties. But I'm not sure if inferred types would help in those cases.