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
+12.7k Golang : Convert(cast) uintptr to string example
+10.4k Golang : Simple File Server
+8k Swift : Convert (cast) Character to Integer?
+4.7k Unix/Linux : secure copying between servers with SCP command examples
+9.4k Golang : Populate slice with sequential integers example
+13.2k Facebook PHP getUser() returns 0
+16.6k Golang : Get own process identifier
+15.1k Golang : invalid character ',' looking for beginning of value
+8.1k Your page has meta tags in the body instead of the head
+5.9k Golang : How to write backslash in string?
+9.2k Golang : Scramble and unscramble text message by randomly replacing words
+6.6k Mac OSX : Find large files by size