Pretty self evident question…When using .push() on an array in javascript, is the object pushed into the array a pointer (shallow) or the actual object (deep) regardless of type.
Pretty self evident question…When using .push() on an array in javascript, is the object
Share
It depends upon what you’re pushing. Objects and arrays are pushed as a pointer to the original object . Built-in primitive types like numbers or booleans are pushed as a copy. So, since objects are not copied in any way, there’s no deep or shallow copy for them.
Here’s a working snippet that shows it: