Skip to content

Commit 69fee3a

Browse files
authored
[JavaScript] Support for the nullish coalescing assignment (??=) operator (#3830)
1 parent 38ae646 commit 69fee3a

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

javascript/javascript/JavaScriptLexer.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ BitAndAssign: '&=';
9696
BitXorAssign: '^=';
9797
BitOrAssign: '|=';
9898
PowerAssign: '**=';
99+
NullishCoalescingAssign: '??=';
99100
ARROW: '=>';
100101

101102
/// Null Literals

javascript/javascript/JavaScriptParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ assignmentOperator
444444
| '^='
445445
| '|='
446446
| '**='
447+
| '??='
447448
;
448449

449450
literal

javascript/javascript/examples/Misc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ var g = [,,]; // [undefined,undefined]
3737
function f([asdfg]=12345){}
3838
/* TODO:
3939
function async (proc, ...params) {}
40-
var async = 1;*/
40+
var async = 1;*/
41+
42+
const a = { duration: 50 };
43+
a.duration ??= 10;

0 commit comments

Comments
 (0)