js数组去重

/**
* 数组去重
* @param {*数组} songs
*/
export function arrayUnique(songs) {
const result = {};
const finalResult = [];
for (let i = songs.length - 1; i >= 0; i--) {
result[songs[i].name] = songs[i];
}
Object.keys(result).map((item) => finalResult.push(result[item]));
return finalResult;
}
原文地址:https://www.cnblogs.com/ChineseLiao/p/10650036.html