Home >Operation and Maintenance >Safety >How to implement empty array in Javascript
If you want to clear an array, just set the length of the array to 0. Well, this is a bit simple.
var plants = ['Saturn', 'Earth', 'Uranus', 'Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter']; plants.length = 0; console.log(plants); // []
The above is the detailed content of How to implement empty array in Javascript. For more information, please follow other related articles on the PHP Chinese website!