make Array empty in JavaScript

 

The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place. To access a portion of an array without modifying it, see slice().

 

let arr = [1, 2, 3];

arr.splice(0);

console.log(arr); 

Tags:

Share:

Related posts