Javascript- is there a way to destroy all elements of an array by one command?

javascript

Solution

This will create a new empty array `Passengers = []`. Not sure about what you should do.

Or just `Passengers.length = 0;`

Problem

my script creates an empty array and then fill it. But if new arguments come then script is expected to destroy old one and create new one. ``` var Passengers = new Array(); function FillPassengers(count){ for(var i=0;i<count;i++) Passengers[i] = i; } ``` I wanna destroy the old one because new count may be less than old one and last elements of array still will store old array? is that right and if it is how can I destroy it?

Original source

Related problems