Version
2.5.9
Reproduction link
https://jsfiddle.net/arwany/uyndonrp/
Steps to reproduce
After the page loads, the array "persons" will be loaded with one item (Thomas).
Now I have provided two buttons to demonstrate the issue/bug I am having:
- " Add - OK": this button pushes new object to the array by passing the object in clear js object format.
- " Add - NOT OK": this button pushes new object to the array by passing an already defined object above (newPerson).
If you click the "Add NOT OK" button two times, and try to change the value of the array in the gray boxes, you will notice that both the object newPerson and the array objects are being changed, as if vue has added them by reference instead of adding them by value (is it even possible?).
What is expected?
To copy the newPerson variable into the array and leave it alone.
Also, when adding multiple objects, I expect to be seperated from each other, but now they seem to be changed all at the same time.
What is actually happening?
I suspect that pushing the object into the array is being added by reference instead of being added by value.
Is this an issue/feature with Javascript or with vue itself?