array.filter(callback(element, index, array), this)
const words = ['spray', 'applejuice', 'snack', 'notebook', 'masque']
const func = (el, i, arr) => {
console.log(`el: ${el}, i: ${i}, arr: ${arr}`)
return el.length > 6;
}
const result = words.filter(func);
console.log(result)
// 콘솔 결과 : 'el: spray, i: 0, arr: spray,applejuice,snack,notebook,masque' ...
// [ 'applejuice', 'notebook' ]
=> 조건에 맞는 요소들만 돌려뽑아서 배열로 재반환해주는 메서드!