Array Memory Reference
Memory Reference
Each array has its own memory reference
- Arrays are distinct even with identical content
Array("asdf") === Array("asdf") // false
Strict Comparison
===
is a strict equality, not identity operator.
- Strict equality operator on object and array are checked to see if they point/reference to the same
memory address
. - Since every new object/array has its own memory address, two arrays or any two objects created cannot be equal even if the contents of the two arrays or objects are identical.
Identical looking object/array content doesn't mean they are pointing to the same memory
Shallow vs Deep Copy [link]
Shallow copy
creates another reference to the same object.
Deep copy
creates another object with exact values copied (hence, not referencing the original object)
