Guest practice: this set is not saved and does not count.
What does this log?
const s = new Set([2, "2", 2, { a: 1 }, { a: 1 }, NaN, NaN, NaN]); console.log(s.size);
A Set has map, filter and sort methods, just like an array.
map
filter
sort
const a = new Set([1, 2, 3]); const b = new Set([3, 4]); console.log([...a.symmetricDifference(b)]);
const ws = new WeakSet(); const o = {}; ws.add(o); console.log(ws.has(o), ws.has({}), ws.size);
A regular Set keeps an object in memory even after the variable that referred to it is set to null, but a WeakSet does not.
null
Click a question to go back and check it. After you submit, you will see the right answer and an explanation for every question. As a guest, nothing is saved.
Check my answers