What s wrong about arrays and objects?

That’s because grupname is a primitive value. This issue affects only objects, because they are effectively copied and assigned by reference. And although I still we’re better off thinking of objects and arrays as completely separate beasts, this is one case where the fact that arrays are indeed objects at the bare-bones language level means that arrays are similarly affected. I still think lodash’s cloneDeep() should be your go-to option in cases like this.