const a = { duration: 50 };
a.duration ??= 10;
a.speed ??= 25;
console.log(a.duration); // Expected output: 50
console.log(a.speed); // Expected output: 25
Replacement for:
a.duration = a.duration ?? 10
const a = { duration: 50 };
a.duration ??= 10;
a.speed ??= 25;
console.log(a.duration); // Expected output: 50
console.log(a.speed); // Expected output: 25
Replacement for:
a.duration = a.duration ?? 10