Home  >  Article  >  Operation and Maintenance  >  How to implement empty array in Javascript

How to implement empty array in Javascript

WBOY
WBOYforward
2023-05-19 20:12:141047browse

Empty Array

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete