I have a javascript class like,
class Snake{
constructor(id, trail){
this.velocityX = 0;
this.velocityY = -1;
this.trail = trail;
this.id = id;
}
moveRight(){
console.log('move');
}
}
and an array that stores Snake objects.
this.snakeList = new Array();
this.snakeList.push(new Snake(10, newSnakeTrail));
this.snakeList.push(new Snake(20, newSnakeTrail));
this.snakeList.push(new Snake(30, newSnakeTrail));
this.snakeList.push(new Snake(22, newSnakeTrail));
this.snakeList.push(new Snake(40, newSnakeTrail));
For example, I want to remove the element from the array which id is 20.
How can I do that?