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
+23.7k Golang : Storing cookies in http.CookieJar example
+18.6k Android Studio : AlertDialog and EditText to get user string input example
+37.7k Golang : How to read CSV file
+11.2k Golang : Search and extract certain XML data example
+27.8k Golang : Get first few and last few characters from string
+14.1k Golang : Get digits from integer before and after given position example
+5.6k Golang : How to validate ISBN?
+25.1k Golang : Encrypt and decrypt data with AES crypto
+6k Golang : Transform lisp or spinal case to Pascal case example
+3.8k Linux : How to set root password in Linux Mint
+25.5k PHP : Convert(cast) string to bigInt
+16.5k Golang : Simple client server example