开发者

merging arrays with jquery grep

开发者 https://www.devze.com 2023-03-05 18:12 出处:网络
I have two array ArrayA and ArrayB. Array B may have some values in it that belong to ArrayA. I\'m looking to have ArrayB contain all the values of ArrayA. So far, th开发者_运维百科is is what I have:

I have two array ArrayA and ArrayB. Array B may have some values in it that belong to ArrayA. I'm looking to have ArrayB contain all the values of ArrayA. So far, th开发者_运维百科is is what I have:

for (i=0 ; i < ArrayB.length; i++)
{
  ArrayB = jQuery.grep(ArrayB, function (a) {
  ....
  };
};

I'm having some trouble with this function. Please let me know if you have any suggestions. Thanks.


ArrayB = jQuery.grep(ArrayB, function (a,i){
                   return jQuery.inArray(a, ArrayA) != -1;
         });
0

精彩评论

暂无评论...
验证码 换一张
取 消