ES6实现字符串去重 var str = "aaabhusdauvsvsjkdsavv"; //将字符串分割为数组 var arr = str.split(""); //通过set自动去重的特性 arr = [...new Set(arr)]; //将去重的数组拼接成字符串 var str2 = arr.join("");