Support logical assignments
See original GitHub issueLogical assignment proposal is now Stage 4.
https://github.com/tc39/proposal-logical-assignment
ESLint’s default parser will support this syntax under ecmaVersion: 2021
- ESTree: https://github.com/estree/estree/pull/233
- Acorn: https://github.com/acornjs/acorn/pull/968
- Espree: https://github.com/eslint/espree/pull/448
- ESLint:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:10 (6 by maintainers)
Top Results From Across the Web
"logical assignment" | Can I use... Support tables for HTML5 ...
"Can I use" provides up-to-date browser support tables for support of front-end web technologies ... JavaScript operator: Logical OR assignment ( x ||=...
Read more >Logical OR assignment (||=) - JavaScript - MDN Web Docs
The logical OR assignment (x ||= y) operator only assigns if x is falsy.
Read more >Logical assignment - V8 JavaScript engine
JavaScript now supports compound assignment with logical operations.
Read more >ES 12/2021 introduces new logical assignment operators
Logical nullish assignment operator assigns a value to a variable if it is currently nullish ( undefined or null ).
Read more >Did You Know This JavaScript Trick? (Logical Assignment)
In today's video we'll be taking a look at Logical Assignment in JavaScript which lets you re-assign a variable depending on if it's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ESLint also supports logical assignment operators, as of v7.8.0.
If you’re using the default parser, just update the
ecmaVersion
to the latest2021
:The core and most of the rules have been updated in v7.8.0.
We left this issue open for changes that were considered to be breaking for
babel-eslint
users, and those changes will be implemented in ESLint v8. There are also some minor changes that were blocked at the moment, we’ll implement them in some of the future v7 minor releases.@aduh95 this isn’t valid VariableStatement,
||= bar
cannot be Initializer. This code is syntax error in engines, too.