Skip to content

[1-team] June 리팩토링 & 과제 추가#23

Merged
InSeong-So merged 7 commits intopagers-org:1-teamfrom
june6723:chatper2/team1/june
Jan 30, 2023
Merged

[1-team] June 리팩토링 & 과제 추가#23
InSeong-So merged 7 commits intopagers-org:1-teamfrom
june6723:chatper2/team1/june

Conversation

@june6723
Copy link

No description provided.

@june6723 june6723 changed the title [Team 1] June 리팩토링 [1-team] June 리팩토링 Jan 11, 2023
@june6723 june6723 force-pushed the chatper2/team1/june branch from 7471674 to 3cb2715 Compare January 11, 2023 14:44
}

const forEach = (arr, callback) => {
if (!('length' in arr)) throw '배열이 아님!';
Copy link
Member

Choose a reason for hiding this comment

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

in보다는 hasOwnProperty를 사용하는 것을 어떨까요?!
length는 array에 포함된 프로퍼티이기에 in연산자로 프로토타입 체인을 확인할 필요가 없을 것 같아 의견내봅니다 ㅎㅎ!

Copy link
Author

Choose a reason for hiding this comment

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

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty#direct_vs._inherited_properties

와우 조이 의견 너무 땡큐입니다
덕분에 하나 알았네요
Array는 생성하면 prototype 체인 말고도 length를 field 값으로 가지고 있네요

Comment on lines 23 to 27
while (index < arr.length) {
const current = arr[index];
callback(current, index, arr);
index += 1;
}
Copy link
Member

Choose a reason for hiding this comment

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

for문도 결국 while문으로 만들어진다는 이유로 while문 사용하신걸까요? 🤔

Copy link
Author

Choose a reason for hiding this comment

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

맞습니다 ㅋㅋ

};

fetchFlow(user, getUserData, logToSnapErrors);
// 3. setUserData가 추가된다면?
Copy link
Member

Choose a reason for hiding this comment

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

우와 새로운 시나리오로 체크하는 것도 너무 좋아요 :)

@june6723 june6723 changed the title [1-team] June 리팩토링 [1-team] June 리팩토링 & 과제 추가 Jan 18, 2023
@june6723 june6723 requested a review from areumsheep January 18, 2023 13:01
*/
export const forEach = (arr, callback) => {
if (!('length' in arr)) throw '배열이 아님!';
if (!Object.prototype.hasOwnProperty.call(arr, 'length')) throw '배열이 아님!';
Copy link
Member

Choose a reason for hiding this comment

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

image

arr.hasOwnProperty('length') 요렇게 체크해도 확인가능하지 않을까 생각합니다!

Copy link

@roy-jung roy-jung Jan 19, 2023

Choose a reason for hiding this comment

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

Array.isArray(arr) 요런것도 있어요.
(length로 판단할 경우 유사배열객체도 통과될텐데, 그걸 의도하신거라면 본 댓글은 무시해주세요)

@InSeong-So InSeong-So merged commit c261630 into pagers-org:1-team Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants