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.7k Linux : Disable and enable IPv4 forwarding
+6.2k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+4.9k Python : Convert(cast) bytes to string example
+8.6k Golang : How to join strings?
+13.8k Golang : Human readable time elapsed format such as 5 days ago
+21k Golang : For loop continue,break and range
+16.8k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+10.5k Golang : Select region of interest with mouse click and crop from image
+14.2k Golang : Simple word wrap or line breaking example
+6.5k Golang : Embedded or data bundling example
+6.8k Fix sudo yum hang problem with no output or error messages
+13.5k Golang : reCAPTCHA example