function unique(list) {
var arr = [];
for (var i = 0; i < list.length; i++) {
if (i == 0) arr.push(list[i]);
b = false;
if (arr.length > 0 && i > 0) {
for (var j = 0; j < arr.length; j++) {
if (arr[j].cs_show_name == list[i].cs_show_name) {
b = true;
//break;
}
}
if (!b) {
arr.push(list[i]);
}
}
}
return arr;
}
var array = [{"cb_Name": "Audi Sport","cs_pic": "http://img1.bitautoimg.com/autoalbum/files/20160818/158/1152151587_6.jpg","car_id": 120311,"car_name": "2016款 4.0T Sportback Performance","cs_show_name": "奥迪RS 7","CsPriceRange": "153-171万","cs_id": 3841},{"cb_Name": "Audi Sport","cs_pic": "http://img1.bitautoimg.com/autoalbum/files/20160818/158/1152151587_6.jpg","car_id": 120311,"car_name": "2016款 4.0T Sportback Performance","cs_show_name": "奥迪RS 7","CsPriceRange": "153-171万","cs_id": 3841},{"cb_Name": "Audi Sport","cs_pic": "http://img1.bitautoimg.com/autoalbum/files/20160818/158/1152151587_6.jpg","car_id": 120311,"car_name": "2016款 4.0T Sportback Performance","cs_show_name": "奥迪RS 7","CsPriceRange": "153-171万","cs_id": 3841},{"cb_Name": "Audi Sport","cs_pic": "http://img1.bitautoimg.com/autoalbum/files/20160818/158/1152151587_6.jpg","car_id": 120311,"car_name": "2016款 4.0T Sportback Performance","cs_show_name": "奥迪RS 7","CsPriceRange": "153-171万","cs_id": 3841},{"cb_Name": "Audi Sport","cs_pic": "http://img3.bitautoimg.com/autoalbum/files/20141031/302/1011563023_6.jpg","car_id": 111887,"car_name": "2014款 4.0TFSI quattro","cs_show_name": "奥迪S8","CsPriceRange": "150万","cs_id": 2591},{"cb_Name": "Audi Sport","cs_pic": "http://img3.bitautoimg.com/autoalbum/files/20141031/302/1011563023_6.jpg","car_id": 111887,"car_name": "2014款 4.0TFSI quattro","cs_show_name": "奥迪S8","CsPriceRange": "150万","cs_id": 2591},{"cb_Name": "Audi Sport","cs_pic": "http://img3.bitautoimg.com/autoalbum/files/20141031/302/1011563023_6.jpg","car_id": 111887,"car_name": "2014款 4.0TFSI quattro","cs_show_name": "奥迪S8","CsPriceRange": "150万","cs_id": 2591},{"cb_Name": "Audi Sport","cs_pic": "http://img3.bitautoimg.com/autoalbum/files/20141031/302/1011563023_6.jpg","car_id": 111887,"car_name": "2014款 4.0TFSI quattro","cs_show_name": "奥迪S8","CsPriceRange": "150万","cs_id": 2591},{"cb_Name": "Audi Sport","cs_pic": "http://img1.bitautoimg.com/autoalbum/files/20160822/796/1017007961_6.jpg","car_id": 123700,"car_name": "2017款 V10 Coupe","cs_show_name": "奥迪R8","CsPriceRange": "173-203万","cs_id": 2347}];
alert(unique(array));
var kk = unique(array);
for(j = 0; j < kk.length; j++) {
alert(kk[j].cs_show_name);
}
转载于:https://my.oschina.net/hehongbo/blog/1787386