clock  Mon - Sun 8.00 AM - 8.00 PM
mail  edu@teknowize.com
fb
instagram
play store
pinterest

How To Get All Unique Elements From An Array Using jQuery Function

  Sumit Dey Sarkar
  23 Aug 2022
  JQuery
Imperial Advance Hero Image

How To Get All Unique Elements From An Array Using jQuery Function

In this tutorial we will learn how to get all unique elements from an array using jQuery function.

Basically here we will learn how to get all the unique element from array and if any duplicate element found then it can not show again.

let's see example - 

How to get all unique elements from an array using jQuery function

<!DOCTYPE html>
<html>

<head>
    <title>How to get all unique elements from an array using jQuery function</title>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>

<body>

    <script>
        var sites = ["teknowize.com", "w3school.com", "tutorialpoint.com", "teknowize.com"];

        var uniqueWebSites = sites.filter(function (item, i, sites) {
            return i == sites.indexOf(item);
        });

        alert(uniqueWebSites);
    </script>

</body>

</html>

 

Output

jQuery