The editor below will share with you an example of removing duplicate values from two js arrays. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor and take a look.
The examples are as follows:
//两数组去除重复数值 mergeArray: function(arr1, arr2) { for (var i = 0; i < arr1.length; i++) { for (var j = 0; j < arr2.length; j++) { if (arr1[i] === arr2[j]) { arr1.splice(i, 1); //利用splice函数删除元素,从第i个位置,截取长度为1的元素 } } } //alert(arr1.length) for (var i = 0; i < arr2.length; i++) { arr1.push(arr2[i]); } return arr1; }
The above The example of removing duplicate values from two arrays in js is all the content shared by the editor. I hope it can give you a reference, and I hope you will support the PHP Chinese website.
Related recommendations:
js to achieve simple digital change effects
Must-see js breakpoint debugging experience sharing
The above is the detailed content of js example of removing duplicate values from two arrays_javascript skills. For more information, please follow other related articles on the PHP Chinese website!