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

Fix releated to arrow function #2000

merged 1 commit into from Feb 6, 2019


None yet
3 participants
Copy link

ziishaned commented Feb 6, 2019

No description provided.


This comment has been minimized.

Copy link

arcticicestudio commented Feb 6, 2019

This would print the numbers 2, 3 and 4instead of 1, 2 and 3. The number variable contains the actual value of the index but not the index number itself so there's no need to increment it by one. It doesn't start with 0 only because it processes an array. I think that' the reason you submitted this PR.

To get the index of the currently processed array value use the second return value:

[1, 2, 3].map((number, index) => `A string containing the ${number} at index ${index}.`);

Take a look at the documentation of the function for more details.

Alright, forget what I wrote, it's been out of context. Since the other examples also increment by one this would make sense in this case (even if I don't understand why the number incrementing is used as example at all).

Show resolved Hide resolved

ljharb approved these changes Feb 6, 2019

Copy link

ljharb left a comment

Thanks, makes sense :-)

@ljharb ljharb added the editorial label Feb 6, 2019

@ljharb ljharb force-pushed the ziishaned:master branch from 8896165 to 6ef45d4 Feb 6, 2019

@ljharb ljharb merged commit 6ef45d4 into airbnb:master Feb 6, 2019

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
continuous-integration/travis-ci/push The Travis CI build is in progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment