prevent duplicate ids array javascript code example Example: prevent duplicate entries in javascript array if (array.indexOf(value) === -1) array.push(value);