How to delete elements in a JavaScript array?

Please explain me how to delete elements in a JavaScript array.

Comments

  • use splice()

    yourArray = ['a', 'b', 'c', 'd']; yourArray.splice(2,1);
    
    for (var count = 0; count < yourArray.length; count++) {
        alert(yourArray[count]);
    }
    

    this will display "a", "b", "d"

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion