Sorry if its a very easy question, i tried following some answers in here but i couldnt..
I want to add a NEW object to an array, based on the first one
The way i find that works is this one:
new Vue({
el: "#app",
data: {
name: '', //name isnt inside and object
//failedExample: {name: ''}
array: []
},
methods: {
add(){
this.array.push({name: this.name}) // i push a key:value
//this.array.push(failedExample) // what i wished to do
}
}
});
https://jsfiddle.net/myrgato/6mvx0y1a/
I understand that by using the commented array.push, i would just be adding the same reference to the object over and over, so when i change the value of failedExample.name, it will change in all positions of the array. Is there a way that this doesnt happens? Like, i add the first object, then the next one as a NEW instead of a reference?