Example 1 — Same Array Reference
Prove valueOf() returns the identical object—not a clone.
const numbers = [1, 2, 3, 4, 5];
const result = numbers.valueOf();
console.log(result);
console.log(numbers === result); // true How It Works
- Create an array.
numberspoints to one object. - Call valueOf. Returns that same object into
result. - Contents look identical. Logging shows the same elements.
- === is true. Reference equality confirms there was no copy.

