I have an Arc and a Line class setup in JavaScript for managing a lot of arcs and lines of a canvas. I plan on having an array for managing them and I imagine needing to add or remove elements like an ArrayList.
After Googling around, it seems like JavaScript doesn't directly support this, and that the best case is making an element null when you want to remove it. If I am wrong please let me know. If I am not wrong, what would be the best thing to do? Should I make a function along these lines? (The example just uses integers to make things simple)
var example = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9);
example[2] = null;
example[7] = null;
example = removeNulls(example);
function removeNulls(inArr) {
var newArr = new Array();
for (var i = 0; i < inArr.length; i++) if (inArr[i] != null) newArr.push(inArr[i]);
return newArr;
}