How can you append something to an array in javascript?
I have to add some elements at the end of an array. How to append values to an array in javascript?
1 Answer
5 years ago by Anusha
You can use push() method to append values to an array. Here is a sample to refer.
let names = ['foo','bar', 'mike'];
names.push('john', 'arha');
console.log(names); // prints [ 'foo', 'bar', 'mike', 'john', 'arha' ]
5 years ago by Divya