//ascending order
console.log([1, 2, 0, 1].sort((a, b) => a - b))
//descending order
console.log([1, 2, 0, 1].sort((a, b) => b - a))
Run code snippetHide results
[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]