3 ms·
It's for backwards compatibility with functions that return either the expected value (maybe an array or a string) or false (never true). So you can use it in a
by blowski 5y ago
It's for backwards compatibility with functions that return either the expected value (maybe an array or a string) or false (never true). So you can use it in a union like `foo(): string|false {}`. In that sense, it's not a boolean because it will only ever be a string or false.
- tyingq 5y agoThat makes sense, though you would want a linter or something to check that callers are doing "=== false" and not "== false", since falsy (but not false) values would match the latter.