js的filter方法,找出符合条件的元素和索引

var numberArr =[221,224,226,223,228,230,289];

numberArr.filter(function (item,index) {

if(item>229){
console.log(index); //找出所有大于229的元素
     console.log(index); //找出所有大于229的元素在数组中的索引

}
});
原文地址:https://www.cnblogs.com/sherryweb/p/12761512.html