Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Java by (9.5k points)

I want to add data into an array and I don’t know what the size of the array is beforehand. In c#, I use arraylist and do myArray.Add(object) repeatedly to achieve this. Can anyone tell me how to do this in JavaScript?

1 Answer

0 votes
by (19.7k points)

You can array.push() like below to add another value to it:

var array = [];

array.push(value);

With array.pop(), you can remove an item. 

Interested in Java? Check out this Java Certification by Intellipaat.  

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...