This method is used to remove the first element of the Array Object in JavaScript and returns that removed element. This is the most popular method of Array Object in JavaScript. The syntax of this Method is as follows:
Syntax:
This method returns the single of value which was removed by it.
JavaScript Code:
<html>
<head>
<title>JavaScript Array shift Method</title>
</head>
<body>
<script type="text/javascript">
var number = [101, 4, 5, 6].shift();
document.write("Removed element is : " + number);
</script>
</body>
</html>
Output:
Ask Your Question
Got a programming related question? You may want to post your question here Programming Answers here