목록2024/04/18 (1)
기초공사 (html,css,javascript)
return과 map( )
// 고차함수 1. map ( ) 메서드 - map 메서드는 자신을 호출한 배열의 모든 요소를 순회하면서 인수로 전달받은 콜백 함수를 반복 호출한다. - 배열의 각 요소에 대해 콜백 함수를 실행하고, 이 때 콜백 함수에는 현재 요소(aaa)와 그 요소의 인덱스(i)가 인자로 전달됩니다. const posts = [ { id: 1, title: "안녕하세요-1", }, { id: 2, title: "안녕하세요-2", }, ]; [("안녕하세요-1", "안녕하세요-2>")]; const hello = posts.map((aaa, i) => { //console.log(aaa); //console.log(i); if (i % 2 === 0) return; // 0번째는 참이므로 undefined return ..
academy/JavaScript
2024. 4. 18. 12:05