List different ways of empty an array in javascript?



List different ways of empty an array in javascript?..

Answer / Prabhu Nath Singh

There are several ways to empty an array in JavaScript, such as setting its length to 0: `myArray.length = 0`, using the `slice()` method: `myArray.slice()`, or the `splice()` method with no arguments: `myArray.splice(0)`, and the `Array.from()` function with an empty array as the argument: `Array.from()`.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Interview Questions

What is a name function in javascript & how to define it?

1 Answers  


What is the difference between HTMLCollection and NodeList?

1 Answers  


How do I link an external javascript file to html?

1 Answers  


Is javascript pure object oriented?

1 Answers  


What is the main difference between Client side JavaScript and and Server side Java Script?

7 Answers   Ramco,


What is difference between javascript and jscript?

1 Answers  


what is event bubbling and event capturing in javascript?

1 Answers  


how to create a moving div?

1 Answers  


What is an external javascript?

1 Answers  


What is stack in javascript?

1 Answers  


Difference between private, public and static variable?

1 Answers  


How are event handlers utilized in javascript?

1 Answers  


Categories