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
+9.7k Golang : Removes punctuation or defined delimiter from the user's input
+3.7k JavaScript: Add marker function on Google Map
+5.9k Golang : Transform lisp or spinal case to Pascal case example
+22.7k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+20.5k Golang : How to run Golang application such as web server in the background or as daemon?
+6.5k SSL : How to check if current certificate is sha1 or sha2 from command line
+8.1k Golang : Create and shuffle deck of cards example
+6.4k Golang : Convert(cast) io.Reader type to string
+50.1k Golang : How to get struct field and value by name
+6.8k Golang : Get all countries phone codes
+27.8k Golang : Get time.Duration in year, month, week or day
+9.9k Use systeminfo to find out installed Windows Hotfix(s) or updates