selectedRoles= [1,230]
if(this.selectedRoles.length > 1)
{
this.selectedRoles= this.selectedRoles.splice(0,1);
}
I am trying to delete item at index 0 which is 1 but instead it deletes the item at index 1 which is 230.
Why ?
Because you assigned the output of
splicefunction, which is[1]back to the originalthis.selectedRoles:All you had to do is to remove the assignment, e.g.: