OutputNot attempted
Reference equality, NaN lookups, Set
console.log([1, 2] === [1, 2], [NaN].includes(NaN), [NaN].indexOf(NaN), new Set([NaN, NaN, 0, -0]).size);Spaces and quote style don’t matter · write a thrown error as TypeError
Ctrl Enter
Show answer & explanation
The expected output comes from actually running the snippet; opening this shows it next to the explanation.
Objects compare by reference. includes uses SameValueZero (finds NaN); indexOf uses === (cannot). Set also uses SameValueZero: NaNs collapse, 0 and -0 are the same → size 2.