filter数组过滤

// 筛选出数组中带有a的元素
var arr = ['aaa','bbb','ccc','dddd','adddd','abbbbb'];
var arrs = arr.filter(item => item.indexOf('a') > -1)
console.log(arrs) // ["aaa", "adddd", "abbbbb"]
posted @ 2020-01-03 15:49  Ananiah  阅读(188)  评论(0编辑  收藏  举报