[1-team] June 리팩토링 & 과제 추가#23
Merged
InSeong-So merged 7 commits intopagers-org:1-teamfrom Jan 30, 2023
Merged
Conversation
7471674 to
3cb2715
Compare
areumsheep
reviewed
Jan 11, 2023
src/refactoring/june/example-2.js
Outdated
| } | ||
|
|
||
| const forEach = (arr, callback) => { | ||
| if (!('length' in arr)) throw '배열이 아님!'; |
Member
There was a problem hiding this comment.
in보다는 hasOwnProperty를 사용하는 것을 어떨까요?!
length는 array에 포함된 프로퍼티이기에 in연산자로 프로토타입 체인을 확인할 필요가 없을 것 같아 의견내봅니다 ㅎㅎ!
Author
There was a problem hiding this comment.
와우 조이 의견 너무 땡큐입니다
덕분에 하나 알았네요
Array는 생성하면 prototype 체인 말고도 length를 field 값으로 가지고 있네요
src/refactoring/june/example-2.js
Outdated
Comment on lines
23
to
27
| while (index < arr.length) { | ||
| const current = arr[index]; | ||
| callback(current, index, arr); | ||
| index += 1; | ||
| } |
Member
There was a problem hiding this comment.
for문도 결국 while문으로 만들어진다는 이유로 while문 사용하신걸까요? 🤔
| }; | ||
|
|
||
| fetchFlow(user, getUserData, logToSnapErrors); | ||
| // 3. setUserData가 추가된다면? |
Member
There was a problem hiding this comment.
우와 새로운 시나리오로 체크하는 것도 너무 좋아요 :)
areumsheep
reviewed
Jan 18, 2023
| */ | ||
| export const forEach = (arr, callback) => { | ||
| if (!('length' in arr)) throw '배열이 아님!'; | ||
| if (!Object.prototype.hasOwnProperty.call(arr, 'length')) throw '배열이 아님!'; |
Member
There was a problem hiding this comment.
Array.isArray(arr) 요런것도 있어요.
(length로 판단할 경우 유사배열객체도 통과될텐데, 그걸 의도하신거라면 본 댓글은 무시해주세요)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.