This question has already been answered:
var x=[55,44,55,30,30]=>[55,44,30] This question has already been answered:
var x=[55,44,55,30,30]=>[55,44,30] 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 .
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> Source: https://ru.stackoverflow.com/questions/872087/
All Articles