ItSolutionStuff.com

How to Remove First Element from Array in JQuery?

By Hardik Savani • January 26, 2022
jQuery

Hi Dev,

Today our leading topic is jquery array remove first element. step by step explain how to remove first element from array in jquery. you can understand a concept of remove first element from array jquery. We will use jquery array remove first element.

you can see both example of how to remove first key in jquery array.

let's see example

You can see both example with output so, you can understand, how it works.

Example 1: Remove First Element from Array

<!DOCTYPE html>

<html>

<head>

<title>How to Remove First Element from Jquery Array? - ItSolutionStuff.com</title>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>

</head>

<body>

<script type="text/javascript">

var sites = [ "ItSolutionStuff.com", "HDTuto.com", "NiceSnippets.com", "Hackthestuff.com" ];

sites.shift();

console.log(sites);

</script>

</body>

</html>

Output:

["HDTuto.com", "NiceSnippets.com", "Hackthestuff.com"]

Example 2: Remove Last Element from Jquery Array

<!DOCTYPE html>

<html>

<head>

<title>How to Remove Last Element in Jquery Array? - ItSolutionStuff.com</title>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>

</head>

<body>

<script type="text/javascript">

var sites = [ "ItSolutionStuff.com", "HDTuto.com", "NiceSnippets.com", "Hackthestuff.com" ];

sites.pop();

console.log(sites);

</script>

</body>

</html>

Output:

["ItSolutionStuff.com", "HDTuto.com", "NiceSnippets.com"]

I hope it can help you...

Tags: jQuery
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Jquery Moment Convert String to Date Example

Read Now →

JQuery Moment Subtract Year from Date Example

Read Now →

Add Edit Delete Table Row Example using JQuery

Read Now →

JQuery - How to Push Specific Key and Value in Array?

Read Now →

JQuery Hide and Show Password using Eye Icon Example

Read Now →

How to Get Last Element of Array in Javascript?

Read Now →

How to Remove Specific Value from Array in JQuery?

Read Now →

How to Remove undefined Value from Array in JQuery?

Read Now →

Check and Uncheck All Checkbox using JQuery Example

Read Now →

How to Convert Line Breaks to br in jQuery ?

Read Now →

How to Check Object is Empty or Not in JQuery?

Read Now →