JS Coding Questions Logo
JS Coding Questions
#367💼 Interview💻 Code

How do you empty an array

Advertisement

728x90

You can empty an array quickly by setting the array length to zero.

javascript
1let cities = ["Singapore", "Delhi", "London"];
2
3cities.length = 0; // cities becomes []

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 25

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
367of476