I've found that some people call JavaScript a "dynamically, weakly typed" language, but some even say "untyped"? Which is it really?
-- https:/...
For further actions, you may consider blocking this person and/or reporting abuse
Really great coverage of types!
There are also some issues when checking for booleans since:
Works fine, but depends what you really mean by this condition. If you are checking the actual value of
someObj.isValid
this will enter the if block only if it istrue
but if you are checking ifsomeObj
has the propertyisValid
then this will return false when its value is eitherundefined
orfalse
so we would have to change our if condition:This might be bad practice (correct me if that's the case), but for a beginner it is hard to understand why you need that. Especially if
isValid
is an array or string.Good reminder. Type systems can protect against it. In terms of Flow it is called "sketchy" values. I need to write a small post about it.
Coercion is what is wrong with JavaScript's non-type system IMO. It is the source of too many problems, including security-related ones.
Yeah, I think one of the greatest errors in the language's design was choosing to make invalid math operations return NaN rather than throw an exception. Nine times out of ten, programmers don't intend to multiply 3 by "five", so why not fail immediately and loudly?
Yes in JS coercion rules are pretty nasty
I wrote about untyped languages here