Bob Myers
1 min readAug 31, 2018

--

You’re confused about the difference between “evaluate to” and “coerce to”. In a boolean context, at least in many languages, the question is whether the expression is true or false when coerced to Boolean (as is the case when it is used as the condition in an if statement). That’s entirely different from evaluating to Boolean.

Personally, I’ve never had a bug related to the problem you seem to think is so important. If a particular variable is either undefined (or null) or points to some object, then if (object) is a perfectly valid, readable, concise way to check that it is not undefined or null (in JS, anyway).

--

--

Bob Myers
Bob Myers

Written by Bob Myers

Technologist, writer, Japanologist

Responses (1)