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
+22.2k Golang : Match strings by wildcard patterns with filepath.Match() function
+13.6k Golang : Strings comparison
+37.7k Golang : Comparing date or timestamp
+29.7k Golang : Record voice(audio) from microphone to .WAV file
+19.4k Golang : Fix cannot download, $GOPATH not set error
+17.5k Golang : Find smallest number in array
+16.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+4.9k Javascript : How to get width and height of a div?
+5.8k Unix/Linux : Get reboot history or check when was the last reboot date
+7.1k Golang : Gorrila mux.Vars() function example
+29.5k Golang : Saving(serializing) and reading file with GOB
+14.9k Golang : How to check for empty array string or string?