shift() is an array function from Node.js that is used to delete element from the front of an array.
Syntax:
array_name.shift()
Parameter: This function does not takes any parameter.
Return type: The function returns the array after deleting the element.
The program below demonstrates the working of the function:
Program 1:
function shiftDemo() { arr.shift(); console.log(arr); } var arr=[17, 55, 87, 49, 78]; shiftDemo(); |
chevron_right
filter_none
Output:
[ 55, 87, 49, 78 ]
Program 2:
function shiftDemo() { arr.shift(); console.log(arr); } var arr=['a', 'b']; shiftDemo(); |
chevron_right
filter_none
Output:
[ 'b' ]
Program 3:
let Lang = ["Python", "C", "Java", "JavaScript"]; while ((i = Lang.shift()) !== undefined) { Lang.shift(); } console.log(Lang); |
chevron_right
filter_none
Output:
[]
Recommended Posts:
- Nodejs | Automatic restart NodeJs server with nodemon
- PHP | Ds\Sequence shift() Function
- PHP | Ds\Vector shift() Function
- PHP | Ds\Deque shift() Function
- PHP | SplDoublyLinkedList shift() Function
- Nodejs | GM charcoal() Function
- Nodejs | GM blur() Function
- Nodejs | GM sharpen() Function
- Nodejs | GM drawLine() Function
- Nodejs | GM drawArc() Function
- Nodejs | GM drawPolyline() Function
- Nodejs | GM drawBezier() Function
- Nodejs | GM drawCircle() Function
- Nodejs | GM drawEllipse() Function
- Nodejs | GM drawPolygon() Function
- Nodejs | GM drawRectangle() Function
- Nodejs | GM paint() Function
- Nodejs | GM orderedDither() Function
- Nodejs | GM roll() Function
- Nodejs | GM segment() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

