[Vuejs]-How to remove a value from array in quasar?

1👍

The master.news looks like an object with indexes as keys, you could use the delete operator to remove that property :

let id = 12
delete master.news[id]

0👍

JavaScript splice() method works on an array but as per the data structure, master.news is an object with numbered keys (e.g., 1, 2, 12, etc.). Hence, you can not perform splice directly on it.

To make it work you have to use delete operator.

You can try this :

let id = 12
if (master.news[id]) {
  delete master.news[id]
}

0👍

you can use filter method for remove object from array

arrayName.filter(item => {item.id !== 12})

if your data in object you can use delete operator like this:

delete objectName[12]

Leave a comment