array without duplicates id javascript code example
Example 1: 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;
Example 2: prevent duplicate entries in javascript array
if (array.indexOf(value) === -1) array.push(value);