How do I remove the key 'bar' from an array foo so that 'bar' won't show up in
for(key in foo){alert(key);}
How do I remove the key 'bar' from an array foo so that 'bar' won't show up in
for(key in foo){alert(key);}
there is an important difference between delete and splice:
ORIGINAL ARRAY:
[<1 empty item>, 'one',<3 empty items>, 'five', <3 empty items>,'nine']
AFTER SPLICE (array.splice(1,1)):
[ <4 empty items>, 'five', <3 empty items>, 'nine' ]
AFTER DELETE (delete array[1]):
[ <5 empty items>, 'five', <3 empty items>, 'nine' ]
Array element unset
var ar = [1, 2, 3, 4, 5, 6];
ar.pop(); // returns 6
console.log( ar ); // [1, 2, 3, 4, 5]
var ar = ['zero', 'one', 'two', 'three'];
ar.shift(); // returns "zero"
console.log( ar ); // ["one", "two", "three"]
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var removed = arr.splice(2,2);
var list = ["bar", "baz", "foo", "qux"];
list.splice(0, 2);
// Starting at index position 0, remove two elements ["bar", "baz"] and retains ["foo", "qux"].