How to use push array method?

This is tutorial on how to use push array method in Javascript.

const numbers = [1,2,3];
To add a number use push method like this.
numbers.push(4);
To add another one you can use another one.
numbers.push(5);
Also you can use push method with multiple parameters.
numbers.push(6,7);
You can store that in a variable.
const length = numbers.push(8);
Print it out to see.
console.log("Length is: " + length);

javascript push array

Leave a Reply

Your email address will not be published. Required fields are marked *