Nullish Coalescing operator - Allowed in Chromium?

111 views
Skip to first unread message

Theodore Olsauskas-Warren

unread,
Nov 22, 2022, 7:23:22 PM11/22/22
to Chromium-dev, Eduard Hez, Demetrios Papadopoulos, Reilly Grant
HI Chromium-dev,

I was recently pointed to this document on ECMAScript Features in Chromium when considering code making use of the Nullish Coalescing operator (??). This document doesn't call out the operator at all (not allowed, not banned), neither does the Google JS style guide. This absence was interpreted as the feature being disallowed.

I'm hoping to use this thread to form consensus on this one way or the other, then use it to update that the document (as per the instructions in it). I couldn't find any previous discussion on the topic.

I'd like to open the bidding with a case for explicitly allowing usage of the operator. Aside from enabling a more compact syntax, it can also help avoid accidental usage of "truthy" values via the ternary operator (e.g. return a ? a : b) as, by comparison, the nullish coalescing operator strictly compares against null or undefined.

+cc some folks recently involved in usage of the operator in WebUI.

Theo.
Reply all
Reply to author
Forward
0 new messages