Skip to content

OutputNot attempted

+, ==, null comparisons, Object.is

console.log([] + {}, [] == ![], null == 0, null >= 0, NaN === NaN, Object.is(-0, 0), [1, 2] + [3]);

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.

"+ with an object → strings": [] → "", {} → "[object Object]". "== with a boolean → numbers": ![] is false, so [] == false → "" == 0 → 0 == 0. "null only equals undefined" under ==, but relational ops DO convert null → 0. NaN never equals itself. Object.is tells -0 from 0. Arrays stringify via join(",") → "1,2" + "3".