Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[JavaScript] Nullish coalescing assignment (??=)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_assignment

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

Leave a Reply

Your email address will not be published. Required fields are marked *