Js USES the array length property to empty and truncate arrays
- 2020-03-30 01:21:48
- OfStack
1. Empty the array with length:
<script>
var arr1 = ['aaa','bbbb','//www.jb51.net'];
alert(arr1);
arr1.length = 0;
alert(arr1); //The array is empty
</script>
2. Truncate an array with length:
<script>
var arr1 = ['aaa','bbbb','c','d','e'];
arr1.length = 3;
alert(arr1); //Truncate the array aaa, BBBB,c
</script>