The `push()` method adds the given elements to the end of an array and returns the new length of the array. This method modifies the original array and does not create a new array. It takes one or more elements as its argument and adds them to the end of the array. It can also take a single array as an argument and add its elements to the end of the original array. It is very useful when we want to add elements to an array without knowing the length of the array.
The syntax of the `push()` method is as follows:
array.push(element1, ..., elementN)
Where `element1`, `element2` etc. are the elements to be added to the end of the array.
Worried About Failing Tech Interviews?
Attend our webinar on
"How to nail your next tech interview" and learn
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
Register for Webinar
How you can accelerate your learnings
array.push(element1[, ...[, elementN]])
let arr = [1, 2, 3];
console.log(arr); // Output: [1, 2, 3, 4]