I saw the following in a piece of Typescript code:
const arrayAA: Record<
someSchema['propX'],
typeof arrayBB
> = {};
for (const varB of arrayBB) {
(arrayAA[someStringValue] ??= []).push(varB)
}
What does "??=" mean here?
I can't find anything about "??=" in the docs.
==========
(Edit after the comments)
Ok, it was asked before (although I did a search for "??=" on StackOverflow)
So, this code could (should?) be rewritten as:
if (arrayAA[someStringValue] === undefined || arrayAA[someStringValue] === null) {
arrayAA[someStringValue] = [];
}
arrayAA[someStringValue].push(varB)
(Thanks to Ivar)