This question has already been answered:

var x=[55,44,55,30,30]=>[55,44,30] 

Reported as a duplicate at Grundy. javascript Aug 22 '18 at 15:09 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    3 answers 3

     var x = [55, 44, 55, 30, 30]; for (var i = x.length - 1; i >= 0; i--) { if (x.indexOf(x[i]) != i) x.splice(i, 1); } console.log(x); 

       let x = [55, 44, 55, 30, 30] let unique = [...new Set(x)] console.log(unique) 

      or

       let x = [55, 44, 55, 30, 30] let unique = x.filter((e, i) => x.indexOf(e) === i ) console.log(unique) 

         var x = [55, 44, 55, 30, 30]; var y = []; x.forEach(function(el, i) { if (y.indexOf(el) === -1) { y.push(el); } }) console.log(y); 
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>