c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
JavaScript

How to remove duplicates from JavaScript array?

| | JavaScript

In this article we will discuss how to remove duplicates from JavaScript array. This can be implemented by using filter() method.

Example:

<script type="text/javascript">

    var myArray = ["rasik", "thivan", "mydeen", "rasik"];

    var uniqueItems = myArray.filter(function (value, index, array) {

        return array.indexOf(value) == index

    });

    alert(uniqueItems);

 

  </script>

Output: