filter 方法返回一个新数组,新数组的元素是原数组中经过符合指定筛选条件的全部元素。javascript
Array.filter(function(value,index,arr),thisValue)
eg.java
items = [{"name":"test1", "value":222}, {"name":"tttt", "value":"333"}] items.filter(function(){console.log(arguments)})
eg.数组
const filterByName = a => b => { return b.name.indexOf(a) > -1 } items = items.filter(filterByName('te'))
即筛选出数组中name属性包含‘te’的对象this
换成ES5的写法,即spa
function a (a){ return function (b, index, arr){ return b.name.indexOf(a) > -1 } }