A
A
Aleksandr2017-07-07 18:02:04
JavaScript
Aleksandr, 2017-07-07 18:02:04

Removing same object from array?

changeArray(name, subname, value) {
    if (this.filterArray[name].length < 2) {
        
        this.filterArray[name].push(value)
        var filterId = this.filterArray[name].map((item)=>{
            return item.id
        })

        this.$store.dispatch('table/updateFilter', { name: name, subname: subname, value: filterId});

    }
}

I can’t understand how can I make sure that objects do not fall
into this.filterArray[name]if they have the same id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
longclaps, 2017-07-07
@Sashjkeee

Use Map instead of array, item.id as key.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question