How to append values to a JavaScript array? - Programmers Heaven

Howdy, Stranger!

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

Categories

How to append values to a JavaScript array?

NickFNickF USAPosts: 132Member

I need to append some values to a JavaScript array. Can someone please explain me how to do this?

Tagged:

Comments

  • DavidMDavidM USAPosts: 342Member

    You can use push() function.

    // array initialization
    var newarray= [
        "Apple",
        "Mango",
        "Orange"
    ];
    
    // append new value
    newarray.push("Pineapple");
    
Sign In or Register to comment.