DEV Community

Discussion on: JavaScript: Array Tips and Tricks You Should Know

Collapse
 
redbossrabbit profile image
Ibeh Ubachukwu • Edited

Number 9 is my favorite.
For number 4 if you want to empty an array declared with var or let I think it better to reassign it with an empty array instead:

var fruits = [banana, apple, orange, watermelon, apple, orange, grape, apple];

fruits = []; //do this not fruits.length = 0;
Enter fullscreen mode Exit fullscreen mode