Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

After removing all elements of an array using the splice method, will the value of the array be undefined?

My question is the following:
After removing all elements of an array using the splice method, will the value of the array be undefined?

Thank you.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

After removing all elements from an array, its value is the same array (just without the elements, as it is now empty). You can see that in the code snippet below:

const array = ['a', 'b', 'c'];
console.log('before:', array); // ["a", "b", "c"]

array.splice(0, array.length);
console.log('after:', array); // []
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading