var arr = ["fdg","fgr","fdg","fdg","sdf",];
var str = [];
for(var i = 0,len = arr.length;i < len;i++){
! RegExp(arr[i],"g").test(str.join(",")) && (str.push(arr[i]));
}
// 雙重遍歷去重
for (var j = 0; j <res.length; j++) {
console.log(res[j]);
for(i = j+1; i <res.length; i++){
// ==是判斷對象的某個屬性是否相等;若需要判斷是否是對象,則===
if(res[j].name==res[i].name){res.splice(i,1);i--;}
}
// 追加樣式
}