Skip to content
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

[doc] Array 배열 조작 메서드 내용 보충 #137

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

scl2589
Copy link
Collaborator

@scl2589 scl2589 commented Sep 20, 2021

관련 이슈

#123

요약

기존에 있던 배열 API의 내용을 보충하였고 (예시 추가), 자주 사용하는 새로운 배열 조작 메서드 (filter, map, reduce, forEach)를 추가하였습니다.

@scl2589 scl2589 added the doc 문서 또는 가이드 관련 PR label Sep 20, 2021
@scl2589 scl2589 self-assigned this Sep 20, 2021
@scl2589 scl2589 removed the request for review from daep93 September 20, 2021 05:58
@sewonkimm
Copy link
Collaborator

PR 컨벤션에 맞춰서 제목 앞에 레이블 달아주시면 감사하겠습니다 🙇‍♂️

docs/js/array.md Outdated
Comment on lines 161 to 164

리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자는 누산기 (accumulator)입니다. 함수의 반환값을 누적합니다. 두 번째 인자는 처리할 현재 요소를 말하며, 세 번째 인자는 처리할 요소의 인덱스를 나타냅니다.

함수 뒤에는 누산기의 초깃값을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다.
Copy link
Collaborator

Choose a reason for hiding this comment

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

채린님 안녕하세요! 😄 제안을 하나 해보자면,
매개변수가 여러 개인 메서드들은 문법을 보여준 다음 설명을 하면 더 이해가 쉬울 것 같아요
다음과 같이 문법을 먼저 보여주고,

문법

reduce((accumulator, currentValue, currentIndex, array) => { ... }, initialValue)
Suggested change
리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자는 누산기 (accumulator)입니다. 함수의 반환값을 누적합니다. 두 번째 인자는 처리할 현재 요소를 말하며, 세 번째 인자는 처리할 요소의 인덱스를 나타냅니다.
함수 뒤에는 누산기의 초깃값을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다.
리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자(`accumulator`)는 누산기입니다. 함수의 반환값을 누적합니다. 두 번째 인자(`currentValue`)는 처리할 현재 요소를 말하며, 세 번째 인자(`currentIndex`)는 처리할 요소의 인덱스를 나타냅니다.
함수 뒤에는 누산기의 초깃값(`initialValue`)을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다.

그 뒤에 설명을 하면 좋을 것 같습니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 참고하겠습니다. 감사합니다! :)

docs/js/array.md Outdated
Comment on lines 189 to 193
const copied = []
numbers.forEach(function(number){
copied.push(number)
})
console.log(copied) // [1, 2, 3, 4, 5]
Copy link
Collaborator

Choose a reason for hiding this comment

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

이것은 깨알이지만 통일성을 위해 세미콜론이 추가되면 좋을 것 같습니다! 👍

Suggested change
const copied = []
numbers.forEach(function(number){
copied.push(number)
})
console.log(copied) // [1, 2, 3, 4, 5]
const copied = [];
numbers.forEach(function(number){
copied.push(number);
})
console.log(copied); // [1, 2, 3, 4, 5]

Copy link
Collaborator

@amorfati0310 amorfati0310 left a comment

Choose a reason for hiding this comment

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

안녕하세요 채린님 수고 많으셨습니다. 리뷰 살펴보시고 보완할 부분 적용해보시면 좋을 것 같습니다.

docs/js/array.md Outdated Show resolved Hide resolved
docs/js/array.md Outdated

리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자는 누산기 (accumulator)입니다. 함수의 반환값을 누적합니다. 두 번째 인자는 처리할 현재 요소를 말하며, 세 번째 인자는 처리할 요소의 인덱스를 나타냅니다.

함수 뒤에는 누산기의 초깃값을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다.
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. 숫자 연산 뿐 아니라 누적해서 반환하는 다른 예시도 들어주면 좋을 것 같아요.
    ex)
    group-by

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

group by와 같이 사용하는 부분은 처음 봤어요 :) 예시 감사합니다!

docs/js/array.md Outdated Show resolved Hide resolved
@@ -58,8 +58,138 @@ console.log(arr); // [10, 20]

배열을 조작할 때 주로 사용하는 API는 다음과 같습니다.

- [push()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) : 배열에 데이터 추가 (맨 끝 인덱스부터 추가됨)
Copy link
Collaborator

@amorfati0310 amorfati0310 Sep 30, 2021

Choose a reason for hiding this comment

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

개요로 지금처럼 prototype.methods 설명들 부터 쭈욱 나온 다음에 상세 설명을 하는 구조도 괜찮을 것 같네요.

@scl2589 scl2589 changed the title Array 배열 조작 메서드 내용 보충 [doc] Array 배열 조작 메서드 내용 보충 Oct 3, 2021
Copy link
Collaborator

@jm-chong jm-chong left a comment

Choose a reason for hiding this comment

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

채린님 좋은내용 감사합니다.

배열의 메서드의 종류가 매우 다양한데, 일목요연하게 잘 정리해 주신것 같습니다.

메서드 API들을 소개할때

  • 배열의 원본을 조작하는(mutable) 메서드
    • push, pop, shift, unshift, splice
  • 원본을 조작하지 않고, 새로운 배열을 반환하는 (immutable) 메서드
    • map, filter, reduce, forEach, concat, slice

두가지로 나누면 어떨지 제안 드립니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc 문서 또는 가이드 관련 PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants