remove duplicates from string to number js code example
Example 1: javascript remove duplicates from array
unique = [...new Set(arr)]; // where arr contains duplicate elements
Example 2: remove duplicates strig javascript
const arr = [1, 2, [3, 4]];
// To flat single level array
arr.flat();
// is equivalent to
arr.reduce((acc, val) => acc.concat(val), []);
// [1, 2, 3, 4]
// or with decomposition syntax
const flattened = arr => [].concat(...arr);