Tip # 3 Deleting Array index in Vue.js

Marcos Neves
vuejs-tips
Published in
1 min readMar 3, 2017

Version 2.2 brings a new way to remove a item from array

The standard way in javascript to remove a item from an Array by index, is using array.splice(index, 1)

remove (index) {
this.todos.splice(index, 1)
}

But now in Vue.js 2.2, Vue.delete can do that for you, too:

remove (index) {
this.$delete(this.todos, index)
}

It's not better or faster, just something Vue.delete couldn't do before 2.2.0.

Demo

--

--

Marcos Neves
vuejs-tips

Ancient Brazilian web developer, from php, through Rails to Javascript, Vue.js enthusiast to React.