Write a function which takes array as an argument and remove duplicates elements and returns a new Array in javascript code example
Example 1: js delete duplicates from array
const names = ['John', 'Paul', 'George', 'Ringo', 'John'];
let unique = [...new Set(names)];
console.log(unique); // 'John', 'Paul', 'George', 'Ringo'
Example 2: prevent duplicate entries in javascript array
if (array.indexOf(value) === -1) array.push(value);