
How to shift and unshift using JavaScript?

As the pop() method removes and returns the last element, the shift() method removes and returns the first element of an array object. Since the first element is removed and returned this also affects the length of the array.
<script type="text/javascript">
var rose =["Welcome","to","roseindia","Technologies"];
document.write(rose.shift() + "<br />");
document.write(rose.shift() + "<br />");
document.write(rose);
</script>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.