In a reassignment operation involving primitive data types such as strings, numbers and booleans, the original variable is copied by JavaScript. With non-primitive data types like arrays and objects, only a reference to the values is passed. This is also known as shallow copying. If we instead want to copy an object so that we can modify it without affecting the original object, we need to make a deep copy.
3 Comments
Sort: