It's the nullish coalescing operator that has been proposed for ecmascript and has been implemented in Typescript. You can read more in the Github issue for its implementation or the JavaScript documentation on MDN.
The gist of it is that
const dealType = currentDealType ?? originalDealType;
is equivalent to:
const dealType = currentDealType !== null && currentDealType !== void 0 ? currentDealType : originalDealType;
Or in words: if currentDealType is null or undefined use originalDealType otherwise use currentDealType
It's the nullish coalescing operator that has been proposed for ecmascript and has been implemented in Typescript. You can read more in the Github issue for its implementation or the JavaScript documentation on MDN.
The gist of it is that
const dealType = currentDealType ?? originalDealType;
is equivalent to:
const dealType = currentDealType !== null && currentDealType !== void 0 ? currentDealType : originalDealType;
Or in words: if currentDealType is null or undefined use originalDealType otherwise use currentDealType
?? is the Nullish coalescing operator.
a ?? b evaluates to:
aifais neithernullnorundefinedbotherwise
When chaining ?? such as a ?? b ?? c, you will get the first value from the left that is neither null nor undefined.
So in the example
const dealType = currentDealType ?? originalDealType ?? '';
dealType will be assigned to:
currentDealTypeifcurrentDealTypeis neithernullnorundefined- otherwise
originalDealTypeiforiginalDealTypeis neithernullnorundefined - otherwise
''
Note that a ?? b is different from a || b since
??only checks forundefinedandnull||checks for any falsy value which includesundefined,null,0,NaNand''among others.