📜  “new Set”在nodejs中返回一个空集 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:12.678000             🧑  作者: Mango

代码示例1
Instead of:
const set = new Set(['foo', 'bar', 'baz', 'foo']); // Set(3) { 'foo', 'bar', 'baz' }
const result = [...set] // []

Do:
const set = new Set(['foo', 'bar', 'baz', 'foo']); // Set(3) { 'foo', 'bar', 'baz' }
const result = Array.from(set) // ['foo', 'bar', 'baz']