Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • how to remove duplicate key values from an array using Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 166
    Comment on it

    Hello Reader's, If you have an array having the multiple duplicate key values then by using Javascript you can make them skip. Let's see the example below:-

    Lets say an array full of duplicate data. var axes2=[1,4,5,2,3,1,2,3,4,5,1,3,4];

    var distinct_axes2=[];
    
    for(var i=0;i<axes2.length;i++)
        {
        var str=axes2[i];
        if(distinct_axes2.indexOf(str)==-1)
            {
            distinct_axes2.push(str);
            }
        }
    console.log("distinct_axes2 : "+distinct_axes2); // distinct_axes2 
    

    Output:-

    1,4,5,2,3
    

    Now you can see every value is coming single time.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: