filmov
tv
How to delete array elements using array length property How to empty an array in Javascript
![preview_player](https://i.ytimg.com/vi/uPj9C0I1gRg/maxresdefault.jpg)
Показать описание
Hi
In this small video I explain how to empty an array using length property of array in Javascript.There are many methods to delete all elements of the array.To use length property of array is one of the method to empty an array in Javascript
let arr=[1,2,3,4]
// How to empty an array using length property
In this above example code, I declared an array variable with four elements
later we assign array length as zero
So when we print again the array elements its shows as empty
and when we print length property of array it shows as zero
So by executing
we can delete all elements of the array using array length property
In this small video I explain how to empty an array using length property of array in Javascript.There are many methods to delete all elements of the array.To use length property of array is one of the method to empty an array in Javascript
let arr=[1,2,3,4]
// How to empty an array using length property
In this above example code, I declared an array variable with four elements
later we assign array length as zero
So when we print again the array elements its shows as empty
and when we print length property of array it shows as zero
So by executing
we can delete all elements of the array using array length property