tags:

views:

40

answers:

1

Let's say we have an array with this format:

var thisIsArray = {
   'Cow' : 'Moo',
   'Cat' : 'Meow',
   'Dog' : 'Bark'
};

i wanted to do a function that removes by key:

removeFromArrayByKey('Cow');
+8  A: 
function removeFromArrayByKey(key) {
  delete thisIsArray[key];
}

But I would probably keep it simple and not use the function.

delete thisIsArray[key];
jessegavin
awesome jessegavin!
Martin Ongtangco