You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Topics > Inputs: Clarify the purpose of handling nullables in JS. (#402)
* Topics > Inputs: Clarify the purpose of handling nullables in JS.
- The narrative about "using an or operator" appeared to have missed the
point about the purpose. In fact, there's nothing special about the
"or" (double-pipe || ) logical operator in the JS expression when it
comes to checking the actual underlying type of a union-typed value.
The problem is twofold:
1. The underlying issue is not that the *value* may "contain one of the
exclusive input values"; it's their *type* difference that causes
incompatibilities.
2. For this, the solution is to *handle* the possible types, and it
only happens that in this particular example, a standard "default"
syntax with the shortcircuiting boolean operator would do.
Therefore the content is revised to explicitly warn of the possibility
of encountering the "wrong" type, and give a better rationale of using
the || syntax in the expression.
- Minor normalization of blocks. Use three backticks when these blocks
are siblings without nesting.
* Topics > Inputs: Further clarify how || works in the JS expression
- No need to mention "any other" falsy value
- Quantify the word "expression" to mean the expression as a whole, not
any of its parts that may also stand as an expression.
* Topics > Inputs: Remove the mentions of "truthy" and "falsy".
These terms are too specific to JS, and likely a distraction from the
main point.
0 commit comments