Thank you for stopping by! I am a full-stack developer that combines the power of entrepreneurship and programming to make the lives of programmers easier.
There are also some issues when checking for booleans since:
if (someObj.isValid) { ... }
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 is true but if you are checking if someObj has the property isValid then this will return false when its value is either undefined or false so we would have to change our if condition:
if (someObj.isValid !== undefined) { ... }
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.
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.