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
+27k Golang : Convert file content into array of bytes
+11k Golang : Removes punctuation or defined delimiter from the user's input
+33.2k Golang : How to check if a date is within certain range?
+21.8k Golang : Encrypt and decrypt data with TripleDES
+13.7k Golang : Strings comparison
+10.5k Golang : Generate random integer or float number
+35.3k Golang : Upload and download file to/from AWS S3
+8.8k Golang : Heap sort example
+11.4k Golang : Characters limiter example
+9.3k Golang : does not implement flag.Value (missing Set method)
+10.6k Swift : Convert (cast) String to Integer
+8.6k Golang : How to check variable or object type during runtime?