js delete all from array 1

js delete all from array

var list = [1, 2, 3, 4];
function empty() {
    //empty your array
    list.length = 0;

Here is what the above code is Doing:
1. We create a function called empty()
2. We create a variable called list and assign it an array with 4 elements
3. We call the empty() function
4. The empty() function sets the length of the list array to 0
5. The list array is now empty

Similar Posts