[Vuejs]-Double square brackets in Vue.js data

3👍

Assume each element in the original array has exactly one key / value pair:

arr = [{book:"2"},{phone:"3"},{television:"10"}]

newarr = arr.map(obj => Object.entries(obj)[0])
console.log(newarr)
// [ [ 'book', '2' ], [ 'phone', '3' ], [ 'television', '10' ] ]

Leave a comment