Dave's Brain

Browse - Programming Tips - How can I delete an element from a javaScript array?

Date: 2017nov15
Language: javaScript

Q.  How can I delete an element from a javaScript array?

A.  To delete element 25 from array a

a.split(25,1);
Recall, array indexes are zero-based.
delete a[25]; // WRONG
Only sets it to undefined

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.