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
+8.8k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+26.1k Golang : Calculate future date with time.Add() function
+8.8k Golang : Go as a script or running go with shebang/hashbang style
+15.3k Golang : Force download file example
+7k Golang : Null and nil value
+5.9k Golang : Measure execution time for a function
+25k Golang : Generate MD5 checksum of a file
+4.7k Python : Find out the variable type and determine the type with simple test
+26.5k Golang : How to check if a connection to database is still alive ?
+7.6k Swift : Convert (cast) String to Double
+10.4k Golang : ISO8601 Duration Parser example
+12.9k Golang : How to get a user home directory path?