<html>
<body>
<h1>Array.shift() - Return Value</h1>
<p>The shift() method removes the first item in an array.</p>
<p>This example demonstrates how the shift() method returns the removed item:</p>
<button onclick="myFunction()">Alert the removed item</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.shift();
document.getElementById("demo").innerHTML = fruits;
alert(x);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_shift_return by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 05 Jun 2019 14:01:58 GMT -->
</html>