To clear an array in JavaScript, do this:
while (array.length > 0) array.pop()
.Here's how you do it:
const array = [ 1, 2, 3 ];
while (array.length > 0) array.pop();
console.log(array.length); // 0
while (array.length > 0) array.pop()
.Here's how you do it:
const array = [ 1, 2, 3 ];
while (array.length > 0) array.pop();
console.log(array.length); // 0