Currently, I am utilizing Vue.js in my project and have implemented a method that involves comparing values from two different arrays.
array1: [{ name: 'test1', somevar: true }, { name: 'test2', somevar: false }]
array2: ['test1', 'test3']
compare() {
// In this section, my objective is to access an object property within array1
this.array1.forEach((element) => {
if(this.array1.element.name.includes(this.array2[0])) {
// Upon validation, I aim to remove the compared value from array 1
if(this.array2[0] !== -1) {
var index = this.array1.element.name.indexOf(this.array2[0])
this.array1.splice(index, 1)
}
}
I have identified a potential issue with this.array1.forEach((element)
. How can I effectively access the properties of that specific object?