[Array] filter()

Sejung Seo·2022년 6월 26일
0

JavaScript

목록 보기
5/19
post-thumbnail

filter()

filter() 메서드는 주어진 함수의 테스트를 통과하는 모든 요소를 모아 새로운 배열로 반환합니다.

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);	// output: Array ["exuberant", "destruction", "present"]
profile
공부하는 코린이 🌼

0개의 댓글