var arr2 = [ { name: "name1", num: "1" }, { name: "name2", num: "11" }, { name: "name3", num: "12" }, { name: "name4", num: "13" }, { name: "name2", num: "1" }, { name: "name6", num: "12" } ] function arrayUnique2(arr, name) { var hash = {}; return arr.reduce(function (item, next) { hash[next[name]] ? '' : hash[next[name]] = true && item.push(next); return item; }, []); } console.log(arrayUnique2(arr2, "name")); console.log(arrayUnique2(arr2, "num")); var obj = {C旅遊_I景點: 1, C旅遊_I畢業旅行: 0.55, C旅遊_I旅遊攻略: 0.26}; var arry=[] for (const key in obj) { var new_arry = {tag:'',score:0}; new_arry.tag = key; new_arry.score = obj[key]; arry.push(new_arry); } console.log(arry);