How to Remove Duplicate Value from Array in JQuery?
In this post, i would like to show you how to remove duplicate value from javascript array. we will use jquery filter for remove duplicates value from array. you can simply delete duplicate string in jquery array.
Actually, very few months ago i need to work with jquery array. i have multiple time duplicate value in javascript array. i don't require to display then again and again, i just want to remove that same value in jquery. i had found out the solution of remove duplicates value from array in jquery.
So, here i am going to share simple example, so you can check it:
Example:
<!DOCTYPE html>
<html>
<head>
<title>How to remove duplicate value from array in Jquery? - ItSolutionStuff.com</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
var myArray = ["Hardik", "Paresh", "Sagar", "Hardik", "Rahul"];
var myNewArray = myArray.filter(function(elem, index, self) {
return index === self.indexOf(elem);
});
console.log(myNewArray);
</script>
</body>
</html>
Output:
Array(4)
0: "Hardik"
1: "Paresh"
2: "Sagar"
3: "Rahul"
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. 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, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Remove Duplicate Values from Array in PHP?
- JQuery Notification Popup Box using Toastr JS Example
- How to Get Last Element of Array in Javascript?
- How to Check Image Loaded or Not in JQuery?
- How to Check If Element is Exists or Not in jQuery?
- How to Parse JSON in JQuery Ajax?
- How to Remove Query String from URL using JQuery?
- Check and Uncheck All Checkbox using JQuery Example
- How to access PHP variables in JQuery?
- How to Allow Only One Checkbox Checked at a Time in JQuery?
- How can Make an Array from the Values of Another Array's Key Value?
- How to Check Undefined, Empty and Null in JQuery?
- How to Convert Line Breaks to br in jQuery ?
- How to Check Object is Empty or Not in JQuery?