JQuery to Remove Duplicate Values from an Array in Asp.Net C# VB.Net

Array is a most common data structure of our real life. Without Array some times we can not imagine to develop some logic. It’s a reality. One of the common Array operation is removing duplicate elements from an Array. Here in this article I will explain How we can remove duplicate elements from an Array using JQuery. So lets do the removing duplicate Array elements from client side using JQuery.

Objective/Outcome:
JQuery to Remove Duplicate Values from an Array - Asp.Net Csharp VB.Net

To do the Example add a Label first:

<asp:Label ID="Label1" runat="server" Text=""></asp:Label>

JQuery Code Example to Remove Duplicate Values from an Array:

<script type="text/javascript">
    $(document).ready(function () {
        var MonthList = ["January", "January", "February", "February", "March", "March"];
        MonthList = $.unique(MonthList);
        var Months = "";
        for (var i = 0; i < MonthList.length; i++) {
            if (Months.length == 0)
                Months = MonthList[i];
            else
                Months += "," + MonthList[i];
        }
        var msg = "Original Array with Duplicate Elements: January, January, February, February, March, March <br/><hr/>";
        msg += "Unique Array: " + Months;
        $('#<%=Label1.ClientID%>').html(msg);
        //alert(Months);
    });  
    </script>

Download Code Example C#        Download Code Example VB.Net

Posted in .Net, Asp.net, C#, Client, JQuery, VB.Net

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code
     
 

*