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
+7.7k Golang : Gonum standard normal random numbers example
+17.3k Golang : Example for RSA package functions
+9.1k Golang : Convert file content to Hex
+25.7k Golang : Find files by name - cross platform example
+4.9k Golang : Launching your executable inside a console under Linux
+7k Golang : Multiplexer with net/http and map
+9.5k Golang : Get currencies exchange rates example
+11.7k Python : Convert IPv6 address to decimal and back to IPv6
+6.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+5.6k Golang : Gargish-English language translator
+15.3k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+12k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message