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 } }