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.7k Golang : Strings to lowercase and uppercase example
+9.9k Golang : ffmpeg with os/exec.Command() returns non-zero status
+19.4k Golang : How to count the number of repeated characters in a string?
+13k Swift : Convert (cast) Int to String ?
+7.5k Android Studio : How to detect camera, activate and capture example
+23k Golang : Test file read write permission example
+5.7k Golang : Struct field tags and what is their purpose?
+21.2k Golang : Get password from console input without echo or masked
+10.3k Golang : How to profile or log time spend on execution?
+20.2k Golang : Convert seconds to human readable time format example
+7k Golang : Fibonacci number generator examples
+7.2k Golang : Get environment variable