Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k 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 (106k points)
edited by

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).

If you are passionate to pursue a career in Web Development, you can take up Web Development Online Courses by Intellipaat!

Related questions

Browse Categories

...