js filter用法

1、filter 充当过滤器的作用,以下例子是在input[class=category]中过滤出’value=type ‘的input 

var stone = $('input[class=category]').filter('[value='+type+']');
2、复杂点的例子,
function whatDoesItDo(arr){
 return arr.filter(function(elem, pos) {
return arr.indexOf(elem) == pos;
});
};
原文地址:https://www.cnblogs.com/hanb/p/6509583.html