Skip to content

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

Merged
merged 1 commit into from
Jul 5, 2018
Merged

Updated Arrays Section #1854

merged 1 commit into from
Jul 5, 2018

Conversation

maurozenoni
Copy link
Contributor

  • corrected paragraph 4.4 (conversion from iterable to array)
  • added paragraph 4.5 (conversion from array-like to array)

Closes #1851

- corrected paragraph 4.4 (conversion from iterable to array)
- added paragraph 4.5 (conversion from array-like to array)
Copy link
Collaborator

@ljharb ljharb left a 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>
Copy link
Collaborator

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>
Copy link
Collaborator

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>
Copy link
Collaborator

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.

Copy link
Collaborator

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ljharb ljharb merged commit 5d1f4b9 into airbnb:master Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants