Skip to content

Commit

Permalink
Update plugin-proposal-logical-assignment-operators.md (#2108)
Browse files Browse the repository at this point in the history
add nullish coalescing assignment example in / out

Co-authored-by: Henry Zhu <hi@henryzoo.com>
  • Loading branch information
scplay and hzoo committed Apr 12, 2021
1 parent 3317331 commit cdc9723
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/plugin-proposal-logical-assignment-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ a && (a = b);
(_obj$a2 = obj.a).b && (_obj$a2.b = c);
```

### With Nullish Coalescing

> While using the `@babel/plugin-proposal-nullish-coalescing-operator` plugin (included in `@babel/preset-env`)
```javascript
a ??= b;
obj.a.b ??= c;
```
```javascript
var _a, _obj$a, _obj$a$b;

(_a = a) !== null && _a !== void 0 ? _a : (a = b);
(_obj$a$b = (_obj$a = obj.a).b) !== null && _obj$a$b !== void 0
? _obj$a$b
: (_obj$a.b = c);
```
## Installation
```sh
Expand Down

0 comments on commit cdc9723

Please sign in to comment.