function unique(arr,key){ let hash = {} let res = arr.reduce((total,current)=>{ if(!hash[current[key]]){ hash[current[key]]=true total.push(current) } return total },[]) return res }