Skip to content

Commit dcbec63

Browse files
committed
Adds requested section, closes #3928
1 parent ad022d4 commit dcbec63

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/Language/js-nutshell.pod6

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,21 @@ say 1 +^ 1; # OUTPUT: 0
340340
say +^1; # OUTPUT: -2
341341
=end code
342342
343+
=head3 Checking for definedness
344+
345+
Javascript includes a nullish coalescing operator, C<||>, which progresses
346+
only if null or undefined:
347+
348+
=for code :lang<javascript>
349+
undefined || null || 0 || 1 ; // => 1
350+
undefined ?? null ?? 0 ?? 1 ; // => 0
351+
352+
This is very similar to Raku L<C<//>|/routine/$SOLIDUS$SOLIDUS> operator:
353+
354+
=for code
355+
(Any) || Nil || 0 || 1 ; # => 1
356+
(Any) // Nil // 0 // 1 ; # => 0
357+
343358
=head3 Custom operators and operator overloading
344359
345360
Node.js does not allow operator overloading without having to use a Makefile or

0 commit comments

Comments
 (0)