Hint
Primitives copy by value; objects copy by reference (the memory address)
Primitive types (string, number, boolean, null, undefined, symbol, bigint) are stored and copied by value.
Reference types (objects, arrays, functions) are stored as pointers. Variables hold a reference β assigning copies the reference, not the object.
// Primitives β copy by value
let a = 5;
let b = a;
b = 10;
console.log(a); // 5 β completely independent
// Objects β copy by reference
let obj1 = { x: 1 };
let obj2 = obj1; // both point to THE SAME object in memory
obj2.x = 99;
console.log(obj1.x); // 99 β obj1 was mutated!
// Reference equality
console.log([] === []); // false β different objects
console.log({} === {}); // false β different objects
// Functions receive references
function mutate(arr) { arr.push(1); }
const myArr = [];
mutate(myArr);
console.log(myArr); // [1] β original was mutated