Vuejs - How to get all unique values in a array (remove duplicates) using v-for
Use reduce to execute a reducer function on each item of the array, then merge the individual matches into the existing object with assign. This merging process takes care of removing (or actually replacing) duplicate items.
const vm = new Vue({ el: '#app', data() { return { allQuestions: [ { id: '123', date: '14' }, { id: '456', date: '2' }, { id: '933', date: '2' }, { id: '789', date: '7' }, { id: '220', date: '14' } ]} }, computed: { uniqueQuestions() { return this.allQuestions.reduce((seed, current) => { return Object.assign(seed, { [current.date]: current }); }, {}); } }});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script><div id="app"> <div v-for="question in uniqueQuestions" :key="question.date"> <button v-for="date in question.date"> {{date}} </button> </div></div>