The push() Function is used to insert new values at the end of the Array.
Let us say, we have a Array that contains three names, Mohan, Kriti and Salim. And we want to insert a new name Nikhil at the last of the Array.
<html>
<body>
<script>
var x = ["Mohan", "Kriti", "Salim"]
x.push("Nikhil")
document.write("[",x,"]")
</script>
</body>
</html>
So, in the above code we have created a Array and initialised to the variable x.
var x = ["Mohan", "Kriti", "Salim"]
Below is how the values are positioned in the Array,
-Function1.png)
Then in the next line, we insert the element at the end of the Array.
x.push("Nikhil")-Function2.png)
And we get the below output,
[Mohan,Kriti,Salim,Nikhil]