Opposite of push();
This question already has an answer here:
Well, you've kind of asked two questions. The opposite of push() (as the question is titled) is pop() .
var exampleArray = ['myName'];
exampleArray.push('hi');
console.log(exampleArray);
exampleArray.pop();
console.log(exampleArray); 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.
上一篇: 从JavaScript数组中删除对象?
下一篇: push()相反;
