unique value from array in javascript code example

Example 1: javascript array unique values

var arr = [55, 44, 65,1,2,3,3,34,5];
var unique = [...new Set(arr)]

//just  var unique = new Set(arr) wont be an array

Example 2: unique values in array javascript

let uniqueItems = [...new Set(items)]

Example 3: get only unique values from array javascript

arr = [2, 2, 2, 1, 3, 3, 3,3, 4, 5];
arr = arr.sort().filter((item,i)=>!(arr[i] == arr[i+1] || arr[i-1]==arr[i]));
// this will remove all item which are repeating more then one
console.log(arr);
// [1, 4, 5]