드림코딩 자바스크립트 기초 강의를 들으며 학습한 내용을 정리해보았다.
⭐️ 재생목록 바로가기
💡 위와 같이 class 생성자 함수를 사용하여 students 라는 배열을 찍어냈다.
이를 활용하여 Array 객체의 APIs를 공부해보자!
vs code에서 command 키 누르고 해당 연산자 클릭해서 설명 확인하기
find()
Returns the value of the first element in the array where predicate is true, and undefined
⬇️ console
⭐️ 화살표 함수, 리턴 한 줄 -> return 선언 생략, 중괄호 생략
⬇️ console
filter()
Returns the elements of an array that meet the condition specified in a callback function.
⬇️ console
map()
Calls a defined callback function on each element of an array, and returns an array that contains the results.
The map method calls the callbackfn function one time for each element in the array.
⭐️ map()의 콜백함수의 인자는 흔히 쓰는 item, value 등 보다는 알아보기 쉬운 이름을 짓는 것이 좋음 ( ex. student )
⬇️ console
⬇️ console
some()
Determines whether the specified callback function returns true for any element of an array.
every()
Determines whether all the members of an array satisfy the specified test.
reduce()
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
⬇️ console
⬇️ console
⬇️ console
📝 코드 정리