JavaScript Shift() Function Example
JavaScript shift() method remove first item in array and return that removed item.
Example
<html>
<head>
<title>JavaScript Array shift() function</title>
</head>
<body>
<script type="text/javascript">
var city = ["Tokyo", "Mumbai", "Delhi", "Las Vegas"];
document.write("Amazing Cities: " + city.join(", ") + "<br />");
document.write(city.shift() + "<br />");
document.write(city + "<br />");
document.write(city.shift() + "<br />");
document.write(city + "<br />");
document.write(city.shift() + "<br />");
document.write(city);
</script>
</body>
</html>
Example Result