๐Ÿšš

Remove array duplicated

javascript

Using Set

const array = ['๐Ÿ‘', 1, 2, '๐Ÿ‘', '๐Ÿ‘', 3]
// Step 1
const uniqueSet = new Set(array)
// Set { '๐Ÿ‘', 1, 2, 3 }
// Step 2
const backToArray = [...new Set(array)]
// ['๐Ÿ‘', 1, 2, 3]
// or Step 1
const uniqueSet = [...new Set(array)]
// ['๐Ÿ‘', 1, 2, 3]

Source: samanthaming.com/tidbi...cates

Edit this page
Want to make your own site like this? Try gatsby-theme-code-notes by Zander Martineau.
Notes on code. My memory bank.