To remove duplicate values from a JSON object

Source: Internet
Author: User

To remove duplicate values from an array

Array.prototype.distinct = function () {
var arr = this,
result = [],
I
J
len = arr.length;
for (i = 0; i < len; i++) {
for (j = i + 1; j < Len; J + +) {
if (arr[i] = = = Arr[j]) {
j = ++i;
}
}
Result.push (Arr[i]);
}
return result;
}

2. Removing duplicate values for JSON array objects

for (var i = 0; i < customerids.length; i++) {
for (var j = i + 1; j < Customerids.length;) {
if (Customerids[i].code = = Customerids[j].code && Customerids[i].shooton = = Customerids[j].shooton && Customerids[i].siteid = = Customerids[j].siteid && Customerids[i].cardbagppurl = = Customerids[j].cardbagppurl ) {
Customerids.splice (j, 1)
} else J + +
}
}

To remove duplicate values from a JSON 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.