In a JavaScript tutorial I saw someone using the ??
operator over a short circuit operator i.e. ||
For Example:
const a = null;
const b = a ?? 0
Which essentially meant use the value of a
and if a
is null
or undefined
use a default value of 0.
But somehow in NodeJS, this results in a syntax error: