Answers for "“new Set” is returning an empty set in nodejs"

0

“new Set” is returning an empty set in nodejs

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']
Posted by: Guest on April-17-2021

Code answers related to "“new Set” is returning an empty set in nodejs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language