Both arrays are rendered on the UI. The second array (“array2”) is a modification of the first (“array1”). I want to modify array2 without array1 changing at all, but haven’t figured out how. It always reflects the same changes as array2.
I’ve tried pushing array1 to a “transitionArray”, modifying that, then pushing to array2:
for (let i = 0; i < this.array1.length; i++) {
transitionArray.push(this.array1[i])
}
(modification...)
for (let i = 0; i < transitionArray.length; i++) {
this.array2.push(transitionArray[i])
}
And then I tried putting array2 in its own method to try and separate array1 and array2 further:
for (let i = 0; i < this.array1.length; i++) {
transitionArray.push(this.array1[i])
}
(modification...)
this.updateCurrentUserSettings(transitionArray)
},
updateCurrentUserSettings(array) {
for (let i = 0; i < array.length; i++) {
this.array2.push(array[i])
}
}
But array1 still updates the same as array2. This seems like an easy fix but for some reason I just can’t find it.
QualityContainer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.