-
Notifications
You must be signed in to change notification settings - Fork 66
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
base: master
Are you sure you want to change the base?
Conversation
PR 컨벤션에 맞춰서 제목 앞에 레이블 달아주시면 감사하겠습니다 🙇♂️ |
docs/js/array.md
Outdated
|
||
리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자는 누산기 (accumulator)입니다. 함수의 반환값을 누적합니다. 두 번째 인자는 처리할 현재 요소를 말하며, 세 번째 인자는 처리할 요소의 인덱스를 나타냅니다. | ||
|
||
함수 뒤에는 누산기의 초깃값을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다. |
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.
채린님 안녕하세요! 😄 제안을 하나 해보자면,
매개변수가 여러 개인 메서드들은 문법을 보여준 다음 설명을 하면 더 이해가 쉬울 것 같아요
다음과 같이 문법을 먼저 보여주고,
문법
reduce((accumulator, currentValue, currentIndex, array) => { ... }, initialValue)
리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자는 누산기 (accumulator)입니다. 함수의 반환값을 누적합니다. 두 번째 인자는 처리할 현재 요소를 말하며, 세 번째 인자는 처리할 요소의 인덱스를 나타냅니다. | |
함수 뒤에는 누산기의 초깃값을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다. | |
리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자(`accumulator`)는 누산기입니다. 함수의 반환값을 누적합니다. 두 번째 인자(`currentValue`)는 처리할 현재 요소를 말하며, 세 번째 인자(`currentIndex`)는 처리할 요소의 인덱스를 나타냅니다. | |
함수 뒤에는 누산기의 초깃값(`initialValue`)을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다. |
그 뒤에 설명을 하면 좋을 것 같습니다.
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.
네 참고하겠습니다. 감사합니다! :)
docs/js/array.md
Outdated
const copied = [] | ||
numbers.forEach(function(number){ | ||
copied.push(number) | ||
}) | ||
console.log(copied) // [1, 2, 3, 4, 5] |
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 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] |
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.
안녕하세요 채린님 수고 많으셨습니다. 리뷰 살펴보시고 보완할 부분 적용해보시면 좋을 것 같습니다.
docs/js/array.md
Outdated
|
||
리듀서 함수는 4개의 인자를 가집니다. 첫 번째 인자는 누산기 (accumulator)입니다. 함수의 반환값을 누적합니다. 두 번째 인자는 처리할 현재 요소를 말하며, 세 번째 인자는 처리할 요소의 인덱스를 나타냅니다. | ||
|
||
함수 뒤에는 누산기의 초깃값을 추가해야 합니다. 이 초깃값을 따로 추가하지 않는다면 기존 배열의 첫 번째 값을 뜻하며, 인덱스는 0이 아닌 1부터 시작합니다. |
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.
- 숫자 연산 뿐 아니라 누적해서 반환하는 다른 예시도 들어주면 좋을 것 같아요.
ex)
group-by
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.
group by와 같이 사용하는 부분은 처음 봤어요 :) 예시 감사합니다!
@@ -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) : 배열에 데이터 추가 (맨 끝 인덱스부터 추가됨) |
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.
개요로 지금처럼 prototype.methods
설명들 부터 쭈욱 나온 다음에 상세 설명을 하는 구조도 괜찮을 것 같네요.
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.
채린님 좋은내용 감사합니다.
배열의 메서드의 종류가 매우 다양한데, 일목요연하게 잘 정리해 주신것 같습니다.
메서드 API들을 소개할때
- 배열의 원본을 조작하는(mutable) 메서드
- push, pop, shift, unshift, splice
- 원본을 조작하지 않고, 새로운 배열을 반환하는 (immutable) 메서드
- map, filter, reduce, forEach, concat, slice
두가지로 나누면 어떨지 제안 드립니다.
관련 이슈
#123
요약
기존에 있던 배열 API의 내용을 보충하였고 (예시 추가), 자주 사용하는 새로운 배열 조작 메서드 (filter, map, reduce, forEach)를 추가하였습니다.