const newArr = Array
.from(arr.reduce((acc, n) => acc.set(n, (acc.get(n) ?? 0) + 1), new Map))
.filter(n => n[1] === 1)
.map(n => n[0]);
arr.splice(0, arr.length, ...Array
.from(arr.reduce((acc, n) => acc.set(n, acc.has(n)), new Map))
.reduce((acc, n) => (n[1] || acc.push(n[0]), acc), [])
);