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.
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
[1주차] 심여은 미션 제출합니다. #5
base: main
Are you sure you want to change the base?
[1주차] 심여은 미션 제출합니다. #5
Changes from 20 commits
89e77a0
db6fbdf
70fcdc8
0ec49be
ce263a0
8dec920
ebf9167
a1d5cdd
5a3602c
ca63868
82d8789
142f541
aab51c6
32c826e
f43362a
6379d37
0d17840
0546dc2
c46b278
1f3acc7
61c6b32
956b42c
0bd49ca
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
이 부분을 JavaScript의 배열 내장 함수를 사용하여 자바스크립트 답게 작성해 보면 좋을 것 같아요! 또한 JavaScript에서 배열을 사용할 때
splice()
나push()
를 사용하는 것보다는 새로운 배열을 만들어 할당하는 방식을 자주 사용합니다 🙂그 이유가 궁금하시다면,,,
JS의 immutability(불변성) 관련된 문제인데 이 글에 자세히 나와 있어서 참고하시면 좋을 것 같아요!
간단히 설명드리자면, 배열의 값을 직접 변경할 경우 디버깅이 어렵고 의도치 않은 결과를 불러올 수 있기 때문에 배열의 값을 직접 변경하는 방식이 아닌 새로운 배열을 만들어 할당하는 방식을 추천합니다. 따라서 값을 직접 변경하는
push()
,splice()
등의 메소드보다 새로운 배열을 반환하는map()
,filter()
혹은spread
연산자를 사용하는 방식을 권장합니다 👀 또한 나중에 React를 사용하실 때에도 배열 불변성을 지켜 주셔야 상태 변화 감지와 성능 최적화 부분에서 용이하답니다!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.
저도 주현님께서 말씀해주신 것과 같이 배열 내장 함수를 사용하는 것이 좋을 것 같습니다! 훨씬 간결해질 것 같습니다!
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.
배열 내장 함수 바로 적용해서 자바에서 자바스크립트로 업그레이드 해보겠습니다!
JS의 불변성에 대해서는 잘 몰랐는데, react에서 state 객체에 불변성을 적용하는 것도 같은 맥락이네요! 또 새롭게 알아갑니다😀
splice()를 사용한 코드는 map()을 사용해서 리팩토링해보겠습니다!
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.
여기도 추후에
filter()
메서드를 사용해 보면 좋을 것 같아요!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.
innerText와 textContent를 구분해서 사용하신 이유가 있으신가요 ?
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.
앗 따로 이유는 없습니다! 코드를 꼼꼼하게 확인하지 못해서 같은 기능에 다른 속성을 사용하고 있었네요ㅠㅠ😮💨 확인 감사합니다!🙇🏻♀️
button 엘리먼트 하나의 텍스트값만 읽어오니까 innerText로 통일해서 사용하는게 맞겠네요!
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.
cursor: pointer
를 추가하면 더 좋을 것 같습니다 😉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.
오 버튼에 추가해보겠습니다!
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.
css 정석대로 야무지게 잘 사용하시네요 멋집니다!