2. The fact that pathological-condition-X of a language is in theory understandable with sufficient study is a total red herring in a broad discussion of that language.
Today, I spent five minutes tracking down a
SyntaxError: Unexpected token u
It was honestly hard to read this as "don't give an un-itialized value to this function or it will end up being passed to JSON.parse that will happily treat undefined as a string".I'd take a NullPointerException with a proper stacktrace everyday.
SyntaxError: Unexpected token u foo.js:123
h foo.js:456
g foo.js:789
f
The issues are* no reference to JSON.parse which is where the error occurred
* the error is not "object has no attribute toString", which would have made it clear what it's happening, but something else derived from having silently coerced "undefined" to string, which obscures what is happening.
As I wrote, it was a five minutes thing, not hours, but it's five minutes I would not have spent if it had been:
TypeError: Cannot read property 'toString' of undefined: [native code]
JSON.parse [native code]
h foo.js:456
g foo.js:789
fBy now I'm sure everyone has seen the WAT talk (https://www.destroyallsoftware.com/talks/wat) which illustrates some of the more obscure (and funny) coercions.
It's ok to say that JS's type coercion is a misfeature, good programmers learn to not throw out the baby with the bathwater.
Rewritten as a general programming language "smell". (That said, I do enjoy me some Javascripting, and I have a side-project with it.)