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
+44.1k Golang : Read tab delimited file with encoding/csv package
+5.1k AWS S3 : Prevent Hotlinking policy
+4.7k Golang : Grab news article text and use NLP to get each paragraph's sentences
+6.3k Golang : Dealing with postal or zip code example
+5.6k Golang : Calculate pivot points for a cross
+3.7k Mac OSX : Get disk partitions' size, type and name
+45.4k Golang : Convert int to byte array([]byte)
+5.2k Javascript : Generate random key with specific length
+6.5k Golang : Detect sample rate, channels or latency with PortAudio
+7.9k Golang : Generate EAN barcode
+4.2k Python : Create Whois client or function example
+18.9k Golang : How to get struct tag and use field name to retrieve data?