Javascript gets a list of two array intersection (duplicates) of items that support list<object>

Source: Internet
Author: User

(function (window) {

var Utils = {

TODO determines if two JSON is equal
Equals:function (param, param2) {
return json.stringify (param) = = = Json.stringify (param2);
},

TODO gets the number of occurrences of the current item in the array
Getcountbyitem:function (Objects,item) {
var count = 0;
for (var i = 0;i < objects.length;i++) {
if (This.equals (Objects[i], item)) {
count++;
}
}
return count;
},
TODO gets a list of items with two array intersections and supports the List<object> code format: [{}]
Getrepeatitems:function (objects,objects2) {
var tempobjects = Objects.concat (OBJECTS2);
var repeatitems = [];
for (var i = 0;i < tempobjects.length;i++) {
var itemCount = This.getcountbyitem (Tempobjects,tempobjects[i]);
if (ItemCount > 1) {
Repeatitems.push (Tempobjects[i]);
Tempobjects[i] = null;
}
}
return repeatitems;
}

};

Window. Utils = Utils;

}) (window);

Javascript gets a list of two array intersection (duplicates) of items, supporting list<object>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.