Opposite of push();

This question already has an answer here:

  • How do I remove a particular element from an array in JavaScript? 63 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/19010.html

    上一篇: 如何在javascript中删除数组中的特定元素

    下一篇: push()相反;