1. Two object literals
Each {} is a distinct object, so === compares their references and returns false.
console.log({} === {}) // false — different referencesTyporithm · medium
Step 1 of 8 · intro card
Copy & Equality
Objects and arrays compare by reference: {} === {} and [1] === [1] are both false because each is a distinct object. Primitives compare by value, so 2 === 2 is true. Object.is(NaN, NaN) is true, where === would be false.
=== on objects and arrays compares identity, not contents. {} === {} is false and [1] === [1] is false because each literal creates a brand-new object with its own reference.
Two variables are === only when they point at the *same* object. Primitives are different: numbers, strings, and booleans compare by their value, so 2 === 2 is true.
Object.is is a stricter sibling of ===. It treats NaN as equal to itself — Object.is(NaN, NaN) is true while NaN === NaN is false — and distinguishes +0 from -0.
{} === {} and [1] === [1] are false — distinct references.
Primitives compare by value, so 2 === 2 is true.
Object.is(NaN, NaN) is true; NaN === NaN is false.
console.log({} === {}) // false — different references
console.log([1] === [1]) // false — different references
console.log(2 === 2) // true — primitives compare by value
console.log(Object.is(NaN, NaN)) // trueConnect each part of the code to the concept before you type.
Each {} is a distinct object, so === compares their references and returns false.
console.log({} === {}) // false — different referencesArrays are objects too; two separate [1] arrays are different references.
console.log([1] === [1]) // false — different referencesPrimitives like numbers compare by their value, so 2 === 2 is true.
console.log(2 === 2) // true — primitives compare by valueObject.is(NaN, NaN) is true, unlike NaN === NaN which is false.
console.log(Object.is(NaN, NaN)) // trueRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.