JSLite實現 js數組數據交集$.intersect

$.intersect

數組交集,此方法並不是jquery方法,屬於JSLite的jquery

js$.intersect([1,2,3,'asdkjf'],[2,3,6,'asdkjf'])
//⇒ [2, 3, "asdkjf"]

JSLite內實現方法...

jsintersect:function(a,b){
    var array=[];
    a.forEach(function(item){
        if(b.indexOf(item)>-1) array.push(item);
    })
    return array;
}
相關文章
相關標籤/搜索