How to remove key value from array in JQuery?

Originally published by Hardik Savani at https://itsolutionstuff.com

You can use any one as you need. we can easily delete key value from array using splice function of JavaScript 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…

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading about JQuery

How to Replace jQuery with Vue?

Making the Move from jQuery to Vue

3 JavaScript libraries to replace jQuery

Best JavaScript Frameworks, Libraries and Tools to Use in 2019

jQuery Full Course - jQuery Tutorial From Beginner to Advanced - Learn jQuery 2019

How To Create Chat App in PHP Using Ajax and JQuery


#jquery #arrays #web-development

How to remove key value from array in JQuery?
78.80 GEEK