In this article, I will share with you how to remove duplicate values from an array in jQuery using filter() with a simple example. as you know many times we will needed this type of functionality in our web application. when you got the unique values from the given array. here I will provide a simple example of how to remove duplicate values from an array and get the unique values from an array in jQuery.
<html lang="en">
<head>
<title>Remove Duplicate Values from an Array in jQuery</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<script>
var my_Array = ["PHP","JavaScript","Java","PHP","Python","Java"];
var NewArray = my_Array.filter(function(element,index,self){
return index === self.indexOf(element);
});
console.log(NewArray);
</script>
</body>
</html>
i hope thi will be help to you.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to Allow Only Numeric Value in HTML Text Input Using jQuery
Use the RegExp test() Method If you w...How to get a website's favicon with PHP
While working with my one of project, I...Laravel5.4 - Prevent Browser's Back Button Login After Logout
In this tutorials we are sharing with yo...How to Check If a String Contains a Specific Word in PHP
Use the PHP strpos() Function You can...Convert Json Data to HTML Table Using json2html Javascript Library
json2html is a easy and fast javasc...