+4 votes
489 views
asked in java script by (2.6k points)

 

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');

1 Answer

0 votes
answered by (2.3k points)

probably this solve your problem

 

function removeFromArrayByKey(key) {
  delete thisIsArray[key];
}

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

delete thisIsArray[key];

Categories

...