Javascript : Empty an array example
Problem :
You have an array in JavaScript and you need to empty it. How to do that?
For instance :
arr := [0,1,2,3,4,5]
Solutions :
1.
while(arr.length > 0) {
arr.pop();
}
2.
arr.length = 0;
3.
arr = [];
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+17.8k Golang : Get RGBA values of each image pixel
+4.5k Swift : Convert string array to array example
+5.2k PageSpeed : Clear or flush cache on web server
+5.8k Fix sudo yum hang problem with no output or error messages
+45.5k Golang : Convert int to byte array([]byte)
+29.6k error: trying to remove "yum", which is protected
+6.9k Golang : Gomobile init produce "iphoneos" cannot be located error
+17.2k Golang : Generate thumbnails from images
+25k Golang : Convert file content into array of bytes
+19.9k Golang : How to get time zone and load different time zone?
+22.4k Golang : Check if element exist in map