Is there a way to empty an array and if so possibly with .remove()?
If we need to keep the original array because we have other references to it that should be updated too, we can clear it without creating a new array by setting its length to zero:
A more cross-browser friendly and more optimal solution will be to use the
splice method to empty the content of the array A as below:
Then we can use it like this:
Or if we want to be sure we don't destroy something: