22.10.09

Javascript array manipulation : splice

use the splice function to remove (an) element(s) from anwywhere in a javascript array without leaving an undefined cell in the middle.

don't forget indexOf for finding elements in the array to delete :)

var idx = mylist.indexOf(elementToDelete)
mylist.splice(idx,idx);
//now it's gone.

No comments:

Post a Comment