something == null ? fallback : something
is prohibited by the equality section and something ?? fallback
is prohibited due to being too new. The next best way would be (typeof something === "undefined" || something === null) ? fallback : something
, which is quite too much of a mouthful. Is there some shorter way I'm not aware of, or is this use case just too niche for the MediaWiki codebase?
Topic on Manual talk:Coding conventions/JavaScript
Appearance
If you know the expected type you could do e.g. !something && something !== ''
.
This post was hidden by Aaron Liu (history)
Ooh, that is smart. It stunned my brain for a minute but it is short and nice. THanks.