array that dont allow duplicates in javascript code example
Example 1: javascript remove duplicates from array
// for TypeScript and JavaScript
const initialArray = ['a', 'a', 'b',]
finalArray = Array.from(new Set(initialArray)); // a, b
Example 2: how to remove duplicate values in array javascript
var car = ["Saab","Volvo","BMW","Saab","BMW",];
var cars = [...new Set(car)]
document.getElementById("demo").innerHTML = cars;