the method is ingenious but to know beforehand that the corresponding name or other property names primary key values only apply to known data objects for invocation;var arr1 = [{ name: ' C30 ' }, { name: ' C35 ' }, { name: ' C40 ' }, { name: ' C45 ' }, { name: ' C50 ' }, { name: ' C60 ' }, { name: ' C55 '}];//take the list in strength settings var arr2 = [{ name: ' C30 ' }, { name: ' C35 '}];//take to the list of current contract details var temp = []; Temporary array 1 var temparray = []; //temporary array 2 for (var i = 0; i < arr2.length; i++) { temp[arr2[i].name] = true; //Ingenious Place: The property value corresponding to the object of array B as the key of the temporary array 1 and assigned a value of true };for (var i = 0; i < arr1.length; i++) { if (!temp[arr1[i].name]) { temparray.push (Arr1[i]) //Clever place: At the same time the array a object corresponding to the property value as a temporary array 1 key and determine whether it is true, If you don't repeat for true, merge into a new array so you can get a newThere is no duplicate array };};/ / document.write (Temparray.join (",") + ""); Console.log (temparray); // var datalist=[{name: ' C30 '},{name: ' C35 '},{name: ' C40 '},{name: ' C45 '},{name: ' C50 '},{name: ' C60 '},{ Name: ' C55 '}]; //to the list in strength settings var rowlist=[{name: ' C30 '},{ Name: ' C35 '}]; //take the list of current contract details function Remove (Arrperson,objpropery,objvalue) { return $.grep ( Arrperson, function (cur,i) { return cur[ objpropery]!=objvalue; }); } for (var i = 0; i < datalist.length; i++) { //all the data to remove the existing data //can consider replacing more efficient algorithms for removal for (var j =0;j < rowlist.length; j++) { if (datalist[i].name== Rowlist[j].name) {&NBSP;&NBSP;&NBSP;&NBsp; //remove the data from the corresponding array //datalist.pop (DataList[i].name) ; datalist = remove (DataList, "name", Rowlist[j].name); } } } a+b js How to merge two arrays and remove duplicates Var a = [1,2,3,4,5];var b = [1,2,4,5];alert (A, B); // displays the corresponding de-weight array function tab (ARR1,ARR2) { var arr = arr1.concat (ARR2); var lastarr = [] ; for (var i = 0;i<arr.length;i++) { if (! unique (Arr[i],lastarr)) { lastarr.push (Arr[i] ); } } return lastarr;} Function unique (N,arr) { for (var i=0;i<arr.length;i++) { if (N==arr[i]) { return true; } } return false;}
JavaScript (jquery) array de-weight algorithm discussion