Optional chaining obj?.[expr]
See original GitHub issueThe obj?.[expr]
syntax of optional chaining don’t work as expected:
Input
let nestedProp = obj?.['prop' + 'Name'];
let arrayItem = arr?.[42];
Expected (no change)
let nestedProp = obj?.['prop' + 'Name'];
let arrayItem = arr?.[42];
Actual
Space between .
and [
let nestedProp = obj?. ['prop' + 'Name'];
let arrayItem = arr?. [42];
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called is ...
Read more >How to Use Optional Chaining in JavaScript - freeCodeCamp
Optional chaining is a safe and concise way to perform access checks for nested object properties. The optional chaining operator ?. takes ...
Read more >JavaScript Optional Chaining Operator (?.)
In this tutorial, you'll learn about the optional chaining operator (?.) that simplifies the way to access values through connected objects.
Read more >How to Use JavaScript Optional Chaining - Dmitri Pavlutin
Optional chaining accesses properties from deep of nested objects without prop existence verification and intermediate variables ...
Read more >Optional chaining (?.) - JavaScript
The value of obj.first is confirmed to be non- null (and non- undefined ) before ... Using optional chaining with function calls causes...
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
@h0rn3z0r Hm, tests: https://github.com/beautify-web/js-beautify/blob/4738a1dc43f95e92190d341aae8e310075a7074a/test/data/javascript/tests.js#L1054-L1075
Ah, I see the problem.
@bitwiseman This issue is not fixed. The latest js-beautify still inserts an extra space character after the optional chaining operator.