Open this example in the interactive library
Source code
const settings = { volume: 0 };
settings.volume ??= 50;
settings.theme ??= "light";
console.log(settings);
Sample output
{ volume: 0, theme: 'light' }
Open this example in the interactive library
const settings = { volume: 0 };
settings.volume ??= 50;
settings.theme ??= "light";
console.log(settings);
{ volume: 0, theme: 'light' }