Delete object from array within javascript

Someone asked me whilst doing a job how to delete parts of a array within javascript, so just like other object oriented languages, you can have a array of data objects and each one can be accessible and removable. To achieve this with javascript you use the delete method as below.

var myArray = new Array();
myArray[0] = "first value";
myArray[1] = "second value";
// and to delete the second value
delete myArray[1];

Leave a Reply

Your email address will not be published. Required fields are marked *