One of the examples is the preallocation of Array. Here's a few paragraph from JS Mythbusters:
Instead of allocate a new Array every time, a good approach in terms of perfomance is reuse the same array instance.
For clean the elements of the Array, you can follow different approach.
Probably the most evident is use .pop in a loop for clean all the elements:
const array = [1, 2, 3, 4, 5] while (array.length) array.pop() console.log(array) // 
However, there is a better and simpler using Array.prototype.length. This property is writable, and, if you set the value to 0, remove all the elements:
const array = [1, 2, 3, 4, 5] array.length = 0 console.log(array) // 
Mind-blown yet? Check out the rest from JS Mythbusters