remove all element in array javascript code example
Example 1: js remove from array by value
const index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
Example 2: js delete all array items
A.splice(0,A.length)
Example 3: js delete all array items
A.length = 0
Example 4: empty array javascript
let myArray = [12 , 222 , 1000 ];
myArray.length = 0; // myArray will be equal to [].