In console this.unselectedPlayerList.length is not shown, It will shown before using splice method. So I have doubt in splice method.
export default class MakeYourTeamChild extends LightningElement {
@api unselectedPlayerList=[];
SelectPlayer(event)
{
for(let index = 0 ; index < this.unselectedPlayerList.length; index++)
{
if(this.unselectedPlayerList[index].Name == event.target.title)
{
this.selectedPlayer = this.unselectedPlayerList[index].Name;
this.unselectedPlayerList.splice(index,1);
console.log('After Splice',this.unselectedPlayerList.length);
}
}
}
}
As per my understanding, we can't update or edit the @api variable by using splice(), push(), and concat() methods. So, you have to replicate the @api variable in another temp variable and implement your logic on that temp variable. Assign back the temp variable to the @api variable. Have a look at the below code for reference:
I hope it will help you. If yes, mark it as the best answer. Feel free to reach out to me!