Shift-3

 

This example will display all the array element one by one after calling shift function. See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <script> var array = new Array(20, 31, 2); while (array .length > 0) { var result = array.shift(); document.write (result.toString() + " "); } </script> </body> </html>
Output