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
+5.1k Golang : Convert Chinese UTF8 characters to Pin Yin
+14k Golang : Get digits from integer before and after given position example
+7.6k Golang : Gaussian blur on image and camera video feed examples
+20.9k Golang : Read directory content with filepath.Walk()
+17.8k Golang : Fix cannot download, $GOPATH not set error
+5.7k Restart Apache or Nginx web server without password prompt
+5.1k Javascript : Get operating system and browser information
+13.4k Golang : Get URI segments by number and assign as variable example
+7.4k Golang : Implementing class(object-oriented programming style)
+3.6k Javascript : Access JSON data example
+10k How to test Facebook App on localhost ?
+28.9k Golang : Calculate percentage change of two values