How would this shortcut nullish operator be in the plain ternary operator syntax
obj = obj[array[i]] ??= {}
What is confusing for me here is the added = after the two ??
How would this shortcut nullish operator be in the plain ternary operator syntax
obj = obj[array[i]] ??= {}
What is confusing for me here is the added = after the two ??
The logical nullish assignment (x ??= y) operator only assigns if x is nullish (null or undefined).
in your question,
if obj[array[i]] equals to null or undefined, then obj[array[i]] will be {}.
checkout the mdn documentation: