Opposite of push();

This question already has an answer here:

  • How do I remove a particular element from an array in JavaScript? 62 answers

  • 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.

    链接地址: http://www.djcxy.com/p/3202.html

    上一篇: 从JavaScript数组中删除对象?

    下一篇: push()相反;