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
+5.9k Golang : Denco multiplexer example
+10.9k PHP : Convert(cast) bigInt to string
+10k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+9k Golang : Populate or initialize struct with values example
+19.7k Golang : Get current URL example
+7.4k Golang : Not able to grep log.Println() output
+8.2k Golang : How To Use Panic and Recover
+15.4k Golang : Accurate and reliable decimal calculations
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+9.5k Golang : Terminate-stay-resident or daemonize your program?
+6.9k Swift : substringWithRange() function example
+25.9k Golang : Daemonizing a simple web server process example