nmattise
8/7/2013 - 9:55 PM

Delete vs Splice in javscript

Delete vs Splice in javscript

var array = ['a', 'b','c', 'd', 'e'];

//Delete the element just makes it undefined

delete array[2];
//gives ['a','b', , 'd','e']

//While Splice

array.splice(0,2);

//Gives ['c','d', 'e']