-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Updated Arrays Section #1854
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
Updated Arrays Section #1854
Conversation
- corrected paragraph 4.4 (conversion from iterable to array) - added paragraph 4.5 (conversion from array-like to array)
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.
Thanks!
README.md
Outdated
@@ -369,8 +369,8 @@ Other Style Guides | |||
const itemsCopy = [...items]; | |||
``` | |||
|
|||
<a name="arrays--from"></a><a name="4.4"></a> | |||
- [4.4](#arrays--from) To convert an array-like object to an array, use spreads `...` instead of [`Array.from`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from). | |||
<a name="arrays--from-iterable"></a><a name="4.4"></a> |
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.
we'll need to keep an <a name="arrays--from"></a>
so that existing links don't break.
README.md
Outdated
@@ -382,8 +382,21 @@ Other Style Guides | |||
const nodes = [...foo]; | |||
``` | |||
|
|||
<a name="arrays--mapping"></a> | |||
- [4.5](#arrays--mapping) Use [Array.from](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from) instead of spread `...` for mapping over iterables, because it avoids creating an intermediate array. | |||
<a name="arrays--from-array-like"></a><a name="4.5"></a> |
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.
there's no need to add this 4.5 anchor here; numbered links are legacy
README.md
Outdated
@@ -393,8 +406,8 @@ Other Style Guides | |||
const baz = Array.from(foo, bar); | |||
``` | |||
|
|||
<a name="arrays--callback-return"></a><a name="4.5"></a> | |||
- [4.6](#arrays--callback-return) Use return statements in array method callbacks. It’s ok to omit the return if the function body consists of a single statement returning an expression without side effects, following [8.2](#arrows--implicit-return). eslint: [`array-callback-return`](https://eslint.org/docs/rules/array-callback-return) | |||
<a name="arrays--callback-return"></a><a name="4.7"></a> |
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.
and none of the others section's links should be renumbered.
99d08f6
to
c6cd43b
Compare
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.
Thanks!
Closes #1851