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.9k Golang : Random Rune generator
+4.4k JavaScript : Rounding number to decimal formats to display currency
+11.8k Golang : Pagination with go-paginator configuration example
+4.9k Python : Create Whois client or function example
+4.4k Linux : sudo yum updates not working
+16.1k Golang : Get IP addresses of a domain name
+5.3k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+28.1k Get file path of temporary file in Go
+8.2k PHP : How to parse ElasticSearch JSON ?
+13.9k Golang : How to convert a number to words
+5.7k PHP : Get client IP address
+4.4k Adding Skype actions such as call and chat into web page examples