주어진 함수의 테스트를 통과하는 모든 요소를 모아 새로운 배열로 반환.
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
["exuberant", "destruction", "present"]
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
'언어 정리 > JavaScript' 카테고리의 다른 글
String.prototype.repeat() (0) | 2022.11.12 |
---|---|
Array.prototype.sort() (0) | 2022.11.12 |
String.prototype.split() (0) | 2022.11.09 |
Array.prototype.reverse() (0) | 2022.11.09 |
Array.prototype.join() (0) | 2022.11.09 |