0 votes
519 views
in Programming by (440 points)

I am trying to append to an array in Javascript is there any way to do this?

 

closed

1 Answer

+1 vote
by (1.7k points)
selected by
 
Best answer

Yes its simple you can use push() to do this

 

// initialize array
var arr = [
    "Hi",
    "Hello",
    "nishant"
];

// append new value to the array
arr.push("Hola");

// display all values
for (var i = 0; i < arr.length; i++) {
    alert(arr[i]);
}
0
by (440 points)
thanks nitu .

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated