JavaScript menyebarkan array tanpa duplikat

// How to ES6 spread arrays without duplicates using Set
// Because each value in the Set has to be unique, the value equality will be checked.
let eventNamesArray = ['onMutation', 'onError']
eventNamesArray = [...new Set([...eventNamesArray, 'onReady', 'onError'])]
// ['onMutation', 'onReady', 'onError']

// if you don't specifically need an array, ie you're going to forEach
// the result, then can work with Set object
const setObj = new Set([...eventNamesArray, 'onReady', 'onError'])
setObj.forEach()
SubZ390