How to remove key value from array in JQuery?

By Hardik Savani | August 13, 2019 | | 557 Viewer | Category : jQuery


I will give simple example of remove key from array jquery. we can easily delete key value pair from jquery array. i will give you two example one for array key remove and another will remove object from array by key value in jquery.

You can use any one as you need. we can easily delete key value from array using splice function of js array. if you have jquery array object and you need to remove it then you can remove it using "delete".

Let's see both example so it can help you for deleting key value from jquery array. so let's see that:

Example 1:

<!DOCTYPE html>

<html>

<head>

<title>How to remove key value from array in JQuery? - ItSolutionStuff.com</title>

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>

</head>

<body>

<script type="text/javascript">

var myArray = ['PHP', 'Laravel', 'Codeigniter'];

myArray.splice(1, 1);

console.log(myArray);

</script>

</body>

</html>

Output:

Array(2)

0: "PHP"

1: "Codeigniter"

Example 2:

<!DOCTYPE html>

<html>

<head>

<title>How to remove key value from array in JQuery? - ItSolutionStuff.com</title>

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>

</head>

<body>

<script type="text/javascript">

var myArray = { php: "PHP", laravel: "Laravel", codeigniter: "Codeigniter" };

delete myArray['laravel'];

console.log(myArray);

</script>

</body>

</html>

Output:

Object

codeigniter: "Codeigniter"

php: "PHP"

I hope it can help you...



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
***Do you want me hire for your Project Work? Then Contact US.


We are Recommending you: