> I stopped at the first example (true + false).
So you never did something like this:
x = performCalculation(getParam1())
y = performCalculation(getParam2())
sum = x + y
only to discover that "performCalculation()" sometimes returns a boolean instead of a number? JS is a dynamically typed language after all and functions like function f(x) {
if (x >= 0) {
return Math.sqrt(x)
} else {
return false
}
}
are perfectly valid. If you use a 3rd party library that uses return values like this, you might run into such case without realising it.Sure, you won't explicitly write "true + false", but "f(x) + g(x)" is not uncommon and might indeed evaluate to "true + false".