有没有一种直接将Set转换为字符串的方法(不需要先将Set转换为数组)?我已经查看了Mozilla 的文档,感觉可能有一种方法可以做到。这是我的做法:
let myset = new Set();
myset.add(3);
myset.add(" Wise ");
myset.add(" Men ");
let setStr = myset.toString();
let setArrStr = Array.from(myset).toString();
console.log("Set to String: " + setStr ); //"Set to String: [object Set]"
console.log("Set to Array to String: " + setArrStr); // "Set to Array to String: 3, Wise , Men "