Hey there! any question in your mind? Ask It Now!.

Popular Categories





I want to append to an array in Javascript is it possible?

0 votes
132 views
asked in Programming by nishant (380 points)

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

 

1 Answer

+1 vote
answered by nitu (1,680 points)
selected by nishant
 
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]);
}
commented by nishant (380 points)
thanks nitu .

Related Questions

+2 votes
1 answer 134 views
+5 votes
1 answer 149 views
asked in Programming by jatin Expert (3,823 points)
+4 votes
1 answer 114 views
+1 vote
2 answers 122 views
+2 votes
1 answer 851 views
+2 votes
3 answers 315 views
asked in Programming by jatin Expert (3,823 points)
+2 votes
1 answer 177 views
–1 vote
0 answers 153 views
0 votes
0 answers 82 views
+1 vote
2 answers 212 views

Not a Member yet?

Ask to Folks Login

My Account
518 Folks are online
0 members and 518 guest online
Your feedback is highly appreciated