What is the output?
const a = { x: 1 };
const b = { x: 1 };
console.log(a == b, JSON.stringify(a) === JSON.stringify(b));
- false true
- true true
- false false
- true false
Objects compare by reference; their serialised forms are identical strings.
Play Problem Solving ▸