#javascriptInputOutput
to empty an array in JavaScript?
let var arrayList = ['a', 'b', 'c', 'd', 'e', 'f'];
Method 1:-
arrayList = [];
This is the most easiest way to make an empty array.
Just assign a blank array .
Method 2:-
arrayList.length = 0;
If you make array length to zero using inbuild length function of JavaScript then you can get empty array .
If you want in details please visit my previous article .
Method 3:-
arrayList.splice(0, arrayList.length);
You can use also splice method to blank an array . so the first element of this method is the position to remove items index and the last one is how many number of items to be removed.