Outline
The most common way to empty an array is by reassigning it to an empty array: array = []
.
But what if the array is a const
and you need to empty it by modification rather than reassignment? Here are two of the simplest strategies:
array.length = 0
array.splice(0)