Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anjanesh's avatar

Logical OR assignment in JavaScript ??=

I came across this at https://laracasts.com/series/build-modern-laravel-apps-using-inertia-js/episodes/13

What does this do in JavaScript ?

I can't seem to google this.

??=

PHP's Null coalescing operator equivalent ?

0 likes
2 replies
thinkverse's avatar
Level 15

Wasn't that hard to find information for it, a simple search for JavaScript operators and you find the Nullish coalescing assignment quite easily. 🤷‍♂️

The nullish coalescing assignment (x ??= y) operator only assigns if x is nullish (null or undefined).

Please or to participate in this conversation.