filter
Filter a list to a new list of the matched items.
list.filter( callback [,thisArg] )
Filters list based on the return value of callback.
var names = new DefineList(["alice","adam","zack","zeffer"]);
var aNames = names.filter(function(name){
return name[0] === "a"
});
aNames //-> DefineList["alice","adam"]
Parameters
- callback
{function(item, index, list)}:A function to call with each element of the DefineList. The three parameters that callback gets passed are:
- item (*) - the element at index.
- index (Integer) - the index of the current element of the list.
- list (DefineList) - the
DefineListthe elements are coming from.
If
callbackreturns a truthy result,itemwill be added to the result. Otherwise, theitemwill be excluded. - thisArg
{Object}:What
thisshould be in thecallback.
Returns
A new instance of this DefineList (may be a subclass), containing the items that passed the filter.
list.filter( props )
Filters items in list based on the property values in props.
var todos = new DefineList([
{name: "dishes", complete: false},
{name: "lawn", complete: true}
]);
var complete = todos.filter({complete: true});
complete //-> DefineList[{name: "lawn", complete: true}]
Parameters
- props
{Object}:An object of key-value properties. Each key and value in
propsmust be present on anitemfor theitemto be in the returned list.