Opposite of push();

Alex picture Alex · Aug 27, 2014 · Viewed 62.2k times · Source

I need help on this problem - 'What is the opposite of the JavaScript push(); method?'

Like say I had a array -

var exampleArray = ['remove'];

I want to push(); the word 'keep' -

exampleArray.push('keep');

How do I delete the string 'remove' from the array?

Answer

Amadan picture Amadan · Aug 27, 2014

push() adds at end; pop() deletes from end.

unshift() adds to front; shift() deletes from front.

splice() can do whatever it wants, wherever it wants.