<html>
<body>
<h1>Array.push() - Return Value</h1>
<p>The push() method adds new items to the end of an array.</p>
<p>This example demonstrates how the push() method returns the length of the array, after the insertion.</p>
<button onclick="myFunction()">Alert the length of the array</button>
<p>The array:</p>
<p id="demo"></p>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
var x = fruits.push("Kiwi");
alert(x);
document.getElementById("demo").innerHTML = fruits;
}
</script>
</body>
</html>