The splice function returns a deleted element or an empty array
The unshift function return value is array length
Maybe,you can change this code
if (index > -1) {
console.log('index', index);
advantages.splice(index, 1);
console.log('advantages', advantages.length);
advantages.unshift(type);
console.log('advantages', advantages.length);
this.setPurchaseAdvantages(advantages);
}
Both of these functions can change the original array, so you don't need to create a new array to operate