Remove Duplicate Value from an Array in JQuery

  532 views   1 year ago jQuery

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.

Author : Harsukh Makwana
Harsukh Makwana

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]