How to Remove Key Value from Array using JQuery?

By Hardik Savani November 5, 2023 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...

Shares