-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Use array destructuring for some simple case #7330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jamesgeorge007
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left couple of comments.
src/document/doc-printer.js
Outdated
| const ind = x[0]; | ||
| const mode = x[1]; | ||
| const doc = x[2]; | ||
| const [ind, mode, doc] = x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const [ind, mode, doc] = x; | |
| const [ind, mode, doc] = cmds.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see the variable x serving it's purpose anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, updated. Thanks!
|
I'm really not sure the readability improves in simple cases like this (with only one variable declared): - const child = node.children[0];
+ const [child] = node.children;Let's keep them as is. |
a3380b6 to
cfcbdaf
Compare
docs/directory)changelog_unreleased/*/pr-XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨