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
+36.2k Golang : Get file last modified date and time
+24.6k Golang : Change file read or write permission example
+10.2k Golang : Edge detection with Sobel method
+12.1k Golang : Convert a rune to unicode style string \u
+10.7k Golang : Simple File Server
+18.9k Golang : Delete duplicate items from a slice/array
+30.7k Golang : Remove characters from string example
+10.5k Golang : Meaning of omitempty in struct's field tag
+4.4k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+26.1k Golang : How to read integer value from standard input ?
+9.2k Golang : Capture text return from exec function example
+7.8k Golang : Test if an input is an Armstrong number example