How to Remove Last Element from Array in JQuery?
Published On: 10/08/2022 | Category:
JQuery

Hello Friends,
This simple article demonstrates of jquery array remove last element. This post will give you simple example of jquery array remove last element example. I would like to share with you how to remove last element from array in jquery. let’s discuss about remove last element from array jquery.
Here, you can see both example of how to remove last key in jquery array.
I will give you a full example of how to remove last key in jquery.
Example 1 : Remove Last Element from Jquery Array<!DOCTYPE html> <html> <head> <title>How to Remove Last Element in Jquery Array? - Tuts-Station.com</title> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> </head> <body> <script type="text/javascript"> var sites = [ "Bhavesh", "Vishal", "Keval", "Mehul" ]; sites.pop(); console.log(sites); </script> </body> </html>Output
[ "Bhavesh", "Vishal", "Keval" ];Example 2: Remove First Element from Array
<!DOCTYPE html> <html> <head> <title>How to Remove First Element in Jquery Array? - Tuts-Station.com</title> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> </head> <body> <script type="text/javascript"> var sites = [ "Bhavesh", "Vishal", "Mehul", "Keval" ]; sites.shift(); console.log(sites); </script> </body> </html>Output
[ "Vishal", "Mehul", "Keval" ]
It will help you...