(JS) filter() (2019/10/14)(보충필요!)
개발노트/Javascript2019. 10. 14. 18:22(JS) filter() (2019/10/14)(보충필요!)

-개념 배열의 한 바퀴 돌면서 걸러내는 메서드이다. array.filter(callbackFunction(element, index, array){}) 1. element 배열을 순회하면서 배열의 값을 출력한다. 2. index 배열을 순회하면서 인덱스 번호를 출력한다. 3. array 배열의 length만큼 배열 전체 값을 출력한다. -사용방법 1. 짝수 걸러내기 let numberArry = [1,2,3,4,5,6,7,8,9,10]; let filterArry = numberArry.filter(function(element){ return element % 2 === 0; }) console.log(filterArry); // [2, 4, 6, 8, 10] 출력 let filterArry = num..

image