We simply need this, although the 'appropriate' syntax is `&?`

. Using `??`

for nullish coalescing was unfortunate:

In proposing the nullish coalescing operator `??`

, there is not much discussion aside from a reference to C#, from which the `??`

syntax was borrowed.

However, this is shortsighted, since C# uses boolean logic, while ES uses truthy logic. We take advantage of the fact that ES `&&`

and `||`

operators will return the actual value of the first operand when short-circuiting occurs, rather than `true`

and `false`

. C# cannot do this, and so is inappropriate to borrow from directly.

In the sense that `&&`

mathematically complements `||`

in truthy logic, we should have added together the operators `&?`

and `|?`

. Here, `|?`

is the proper name for what we today call `??`

, and `&?`

is its complement. The usage of `&`

and `|`

as the first character of the operator is an obvious and natural allusion to the closely related `&&`

and `||`

operators, and similarly connotes their complementary nature. Indeed, we can regard `&?`

and `|?`

as narrowing/specializing `&&`

and `||`

, respectively, so the naming is quite appropriate.

The common names for `&?`

and `|?`

can be simply "nullish AND" and "nullish OR", respectively. Note that where some references define `&&`

and `||`

as "logical AND" and "logical OR", it should be clear by now that there are multiple types of "logic" at play (Boolean, nullish, truthy, etc.) and we should be specific. We love ES's truthy logic and are also now embracing nullish logic!

The need for the `&?`

operator comes up in many cases, as you might expect being the proper mathematical complement of `??`

(ahem.. `|?`

). One example is in using DataLoaders in a GraphQL resolver, where one needs to guard that the key is not nullish, but allow zero as a key. We cannot use `&&`

and we would like to use `&?`

.

```
({ key }) => key &? loader.load(key)
```

Without this, we resort to a silly type predicate function in TypeScript:

```
export const ok = <T>(value: T): value is Exclude<T, null | undefined> =>
// double `not equal` is the operator we need here (`null == undefined`)
(value != undefined || undefined) as boolean;
```

used as

```
({ key }) => ok(key) && loader.load(key)
```

Note that we had to force-cast the result in TypeScript to be able to use a truthy result where a boolean result is expected.

Unfortunately, we also defined `??=`

which carries on the inappropriate C# nomenclature.