比较两个json数组是否有相同的选项

var _result = json.data.result;
                    var count = listxx.length;
                    for (var i = 0; i < count; i++) {
                        var _item = listxx[i];
                        var repeat = false;
                        for (var j = 0; j < _result.length; j++) {
                            if (_item.id == _result[j].id) {
                                repeat = true;
                                break;
                            }
                        }
                        if (repeat) {
                            listxx.splice(i, 1);
                            count--;
                            i--;
                        }
                    }
                    //var boxitem = listxx;
                    //for (var i = 0; i < listxx.length; i++) {
                    //    var _item = listxx[i];
                    //    var repeat = false;
                    //    if ($.inArray(_item.id, resultids) != -1) {
                    //        boxitem.splice(i, 1);
                    //    }
                    //}
原文地址:https://www.cnblogs.com/chenglideyueguang/p/9531020.html