1, the filter value unique
ES6 the set object type, with the unfolding operation ... together, you can use it to create a new array, the array so that only unique values.
eg.
const array = [1, 1, 2, 3, 5, 5, 1] const uniqueArray = [...new Set(array)]; console.log(uniqueArray); // Result: [1, 2, 3, 5]
This method is applicable to an array comprising basic undefined
types: null
, boolean
, , string
and number
. (If you have an object, function, or other array contains an array, you need a different approach!)
Subsequent updates