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
+22.6k Golang : Convert seconds to minutes and remainder seconds
+30k Golang : How to get HTTP request header information?
+9.7k Golang : Extract or copy items from map based on value
+19.5k Golang : Calculate entire request body length during run time
+16.6k Golang : How to implement two-factor authentication?
+17.2k Golang : Get number of CPU cores
+12.8k Golang : Get absolute path to binary for os.Exec function with exec.LookPath
+24.8k Golang : How to validate URL the right way
+31k error: trying to remove "yum", which is protected
+6.7k PHP : Shuffle to display different content or advertisement
+7.3k Golang : Gargish-English language translator