0 votes
1 view
in Web Technology by (30.9k points)

Is there a way to empty an array and if so possibly with .remove()?

For instance,

A = [1,2,3,4];

How can I empty that?

1 Answer

0 votes
by (73.5k points)

There are many ways to empty an array in JavaScript some the important ways are as follows:-

The first way is to use   A = [] and this is the most preferred way. You have another option which is A.length = 0 and lastly, you can use the splice method A.splice(0,A.length).

...