|
|
|
|
|
by Jtsummers
2332 days ago
|
|
That's not really a Javascript problem. That's a dynamically typed language problem. Unless you add some kind of assertion/test at the entry point to a library, the failure will always be postponed to the point of use (or silent if it's never used, until the day someone turns a feature on). If the same sort of issue works differently in Python, the Python library has asserts or other tests, or is using the value at an earlier point so it's more easily discovered. |
|
As pointed out, {}.foo will not cause an error. In Python and any good dynamic language, that will generate an error.
Another problem is all the implicit (silent) type conversions. JavaScript will happily add an Object and an integer, then multiply that by a string. Any sensible type system would not allow that, but JavaScript silently produces a NaN.
The problem isn't that its a dynamic type system, but that the type system ignores things which are clearly problems.