I
I
Igor Fedyaev2020-10-05 20:21:51
Vue.js
Igor Fedyaev, 2020-10-05 20:21:51

Compare two arrays and output the updated array?

Hello guys..
There are two arrays with objects.

arr[0:{id: 1, name: bu, title: Hello, message: error}, 1:{id: 2, name: mu, title: Hello, message: error}]
tempDates[0:{id: 2, name: bu, title: world, message: success}]

The task is to compare two arrays and display the final array with the changes made.
result[0:{id: 1, name: bu, title: Hello, message: error}, 1:{id: 2, name: bu, title: world, message: success}]

Tell me, show me how to do it?
In general, the idea is that there is a table and there are rows where, when the value of one row changes, the values ​​immediately change without refreshing the page. Only the line in which the change occurred. Tried this.$set but the second parameter searches by index. Tried with splice, but not that.
Is there a way to do an id lookup? Or what other solutions are there?
5f7b553e7575f693427404.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Fedyaev, 2020-10-06
@mr_garik

Found a solution and it works. Thanks for the many answers)
If suddenly anyone needs:

for (let i = 0; i < data.data.addEngineer.length; i++) {
                    let item = this.order.filter(x => x.id_order === data.data.addEngineer[i].id_order);
                    item.forEach((found) => {
                        found.first_last_name = data.data.addEngineer[i].first_last_name;
                    });
                }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question