can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
24 lines (16 loc) • 853 B
Markdown
List.prototype.filter filter
can.List.prototype
Filter the elements of a List, returning a new List instance with just filtered items.
`list.filter(filterFunc, context)`
{function(this:*,*,Number,can.List):Boolean} filterFunc(item, index, list) A function to call with each element of the list. Returning `false` will remove the index.
{Object} context The object to use as `this` inside the callback.
A filter function that accepts a function, which is run on every element of the list. If the
filter callback returns true, the list returned will contain this item, false and it will not.
Returns a new can.List instance.
var list = new can.List([1, 2, 3])
// returns new can.List([1, 2])
var filtered = list.filter( function(item, index, list)
{
return item < 3;
});
can.