Remove a Sprite from an array

So I made this array and added sprites on it.


var lineX = 700;
this._buttonList = [];
for (var i = 0; i < 30; i++) {
var button = new Sprite();
button.bitmap = ImageManager.loadPicture('Item');
button.x = 100;
var line = lineX * i;
button.x = button.x + line;
button.y = 300;
this._buttonList.push(button);
this.addChild(this._buttonList);
}


However, I have a function that wants to remove a certain index value from that array. So, I decided to use the splice function. The splicing works, but the array length stays the same. I figured it is because I am not deleting the certain item. So, how can I delete a sprite from the array? I am using this splice by the way:


function move(arr, val) {
var j = 0;
for (var i = 0, l = arr.length; i < l; i++) {
if (arr !== val) {
arr[j++] = arr;
}
}
arr.length = j;
}


I want to delete index 0 for example, but even if I use move(this._buttonList, 0) it won't delete the first sprite on the array. So how can I remove that certain sprite?
Are you using the same reference from the button? and why don't use just use the normal splice function or was that just for show?


You should be able to do something like:

Code:
function removeButton(index) {
  var button = someArray.splice(index, 1)[0];
  Stage.removeChild(button);
}
I see. I wondered why that did not work. I will try this solution now.

Original thread: https://forums.rpgmakerweb.com/threads/remove-a-sprite-from-an-array.55604/