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
+7k Golang : Get environment variable
+12.6k Golang : zlib compress file example
+9.9k Golang : Channels and buffered channels examples
+29.3k Golang : How to create new XML file ?
+14.7k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+25.3k Golang : convert rune to integer value
+6.7k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+7.8k Setting $GOPATH environment variable for Unix/Linux and Windows
+25.6k Golang : How to write CSV data to file
+23.4k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+32.8k Golang : How to check if a date is within certain range?
+25.2k Golang : Convert long hexadecimal with strconv.ParseUint example